#include using namespace std; int main() { int income, outgo, total; int sw; total = 10000; cout << "現在の所持金は " << total << " 円になります。" << endl; // 20回まで記録を付けられます. for (int i = 0; i < 20; i++) { cout << "収入なら 1、支出なら 2、それ以外なら終了です: " << ends; cin >> sw; if (sw != 1 && sw != 2) break; switch (sw) { case 1: cout << "収入はいくらですか? " << ends; cin >> income; total += income; break; case 2: cout << "支出はいくらですか? " << ends; cin >> outgo; total -= outgo; break; } } cout << "現在の所持金は " << total << " 円になります。" << endl; return 0; }