
please wait
#include "stdafx.h" #include <iostream> using namespace std; int main() { int subtotal = 0, total = 0, number = 0; bool input_zero = false; while (true) { cin >> number; if (number == 0) { if (input_zero == false) { input_zero = true; cout << "Subtotal " << subtotal << endl; subtotal = 0 ; } else { cout << "Total " << total << endl; } } else { subtotal += number; total += number; } } return 0; system("pause"); } |
|
|
zero_count = zero_count+1;
can be also written as zero_count += 1;