fork(10) download
  1. #include <iostream>
  2. using namespace std;
  3. // Sumar los nĂºmeros pares y multiplicar los nĂºmeros impares hasta que la suma sea mayor que 50 o el producto mayor que 150.
  4. int main() {
  5. int a,totalP=0,totalI=1;
  6.  
  7. while( true ){
  8. cout << "Ingrese un numero:\n";
  9. cin >> a;
  10.  
  11. if( a%2 == 0 ) totalP += a;
  12. else totalI *= a;
  13.  
  14. if( totalP > 50 || totalI > 150 ) break;
  15. }
  16.  
  17. cout << "Los numeros pares sumaron: " << totalP << "\n";
  18. cout << "Los numeros impares resultaron en: " << totalI << "\n";
  19. // your code goes here
  20. return 0;
  21. }
Success #stdin #stdout 0s 3300KB
stdin
 1 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 5 43654 7867 745 432
stdout
Ingrese un numero:
Ingrese un numero:
Ingrese un numero:
Ingrese un numero:
Ingrese un numero:
Los numeros pares sumaron: 6
Los numeros impares resultaron en: 153