Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program: sumatorias.cc
- // Author: Yoan Pinzon
- // Date: Agosto 30, 2006
- #include <iostream>
- #include <string>
- using namespace std;
- int main(){
- int n, x, t1=0, t2=0, t3=0, t4=0, t5=0, t6=0;
- cout << "Entre n: "; cin >> n;
- for(int i=0; i<n; i++){
- cout << "Entre valor " << i+1 << ": "; cin >> x;
- t1+=(x%2?0:1); t2+=(x%2?1:0);
- t3+=(x%2?0:x); t4+=(x%2?x:0);
- t5+=(x%2?0:x*x); t6+=(x%2?x*x:0);
- }
- cout << "Total numeros pares = " << t1 << endl;
- cout << "Total numeros impares = " << t2 << endl;
- cout << "Sumatoria numeros pares = " << t3 << endl;
- cout << "Sumatoria numeros impares = " << t4 << endl;
- cout << "Sumatoria de los cuadrados de los numeros pares = " << t5 << endl;
- cout << "Sumatoria de los cuadrados de los numeros impares = " << t6 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement