diff options
Diffstat (limited to 'sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp')
| -rw-r--r-- | sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp b/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp new file mode 100644 index 0000000..7f99fd5 --- /dev/null +++ b/sem_2/HLIN202/TP/TP2/ex10/exo10-2.cpp @@ -0,0 +1,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; +} + |
