summaryrefslogtreecommitdiff
path: root/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp
blob: 7f99fd5852bf2e4059641f56b429261ed91911f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream>

int main () {
  int a=0, cpt=0, som=0;
  float moy=0;
  std::cout<<"Entrez des entiers ( rel ), ce programme donne le nombre d'entier positifs entres avant le premier negatif"<<std::endl;
  while ( a >=0 ) {
  std::cin>>a;
  cpt += a>=0 ? 1:0;
  moy += a>0 ? a : 0;
  }
  moy=moy/cpt;
  std::cout<<"Vous avez entre "<< cpt<< " positif avant de rentrer un negatif"<<std::endl;
  std::cout<<"La moyenne des donnes est : " << moy << std::endl;
  return 0;
}