Advertisement
idsystems

CPP_Practica67_Sumatorias

Mar 15th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. // Program: sumatorias.cc
  2. // Author:  Yoan Pinzon
  3. // Date:    Agosto 30, 2006
  4.  
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. int main(){
  11.    int n, x, t1=0, t2=0, t3=0, t4=0, t5=0, t6=0;
  12.  
  13.    cout << "Entre n: "; cin >> n;
  14.    for(int i=0; i<n; i++){
  15.       cout << "Entre valor " << i+1 << ": "; cin >> x;
  16.       t1+=(x%2?0:1); t2+=(x%2?1:0);
  17.       t3+=(x%2?0:x); t4+=(x%2?x:0);
  18.       t5+=(x%2?0:x*x); t6+=(x%2?x*x:0);
  19.    }
  20.    cout << "Total numeros pares = " << t1 << endl;
  21.    cout << "Total numeros impares = " << t2 << endl;
  22.    cout << "Sumatoria numeros pares = " << t3 << endl;
  23.    cout << "Sumatoria numeros impares = " << t4 << endl;
  24.    cout << "Sumatoria de los cuadrados de los numeros pares = " << t5 << endl;
  25.    cout << "Sumatoria de los cuadrados de los numeros impares = " << t6 << endl;
  26.  
  27.    return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement