Advertisement
ferseg

cuantos numeros son positivos negativos y cero

Oct 9th, 2014
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. /*  Autor: Joel Cesar Fernandez Segura
  2.     Fecha: 28/08/2014
  3.     Tema: Vectores y Arreglos
  4. */
  5.  
  6. #include<iostream>
  7. #include<cstdlib>
  8. using namespace std;
  9. void mostrarArray(int []);
  10.  
  11. int main(void){
  12.  
  13.     int array[10];
  14.     int positivos=0,negativos=0,ceros=0;
  15.     system("color 0a");
  16.     cout<<"\n\t\t [ VECTORES EN C++ ]\n\n";
  17.     cout<<"\n[EJERCICIO #2]\n";
  18.     cout<<"\nCALCULA CUANTOS NUMEROS SON POSITIVOS NEGATIVOS Y CEROS\n\n";
  19.     for(int i=0;i<10;i++){
  20.     cout<<"INGRESE ELEMENTO ["<<i+1<<"]:";
  21.     cin>>array[i];
  22.     }
  23.     cout<<"\n\nEL ARREGLO ES :\n";
  24.     mostrarArray(array);
  25.     cout<<endl<<endl<<endl;
  26.  
  27.     for(int i=0;i<10;i++){
  28.         if(array[i]>0) positivos++;
  29.         else if(array[i]<0) negativos++;
  30.         else ceros++;
  31.     }
  32.  
  33.     cout<<"CANTIDAD DE ELEMENTOS POSITIVOS : "<<positivos<<endl<<endl;
  34.  
  35.     cout<<"CANTIDAD DE ELEMENTOS NEGATIVOS : "<<positivos<<endl<<endl;
  36.  
  37.     cout<<"CANTIDAD DE ELEMENTOS CON VALOR CERO : "<<ceros<<endl<<endl;
  38.  
  39.  
  40.     return 0;
  41. }
  42.  
  43. void mostrarArray(int array[]){
  44.  
  45.     for(int i=0;i<10;i++){
  46.     cout<<array[i]<<"  ";
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement