照著題目要求加總donate進來的金額,並在輸入report的時候做輸出。
C++(0.000)
/*******************************************************/
/* UVa 12403 Save Setu */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2015/12/02 */
/*******************************************************/
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
int T;
while( scanf("%d", &T) != EOF ){
int totalMoney = 0;
for( int i = 0 ; i < T ; ++i ){
string cmd;
cin >> cmd;
if( cmd == "donate" ){
int money;
scanf("%d", &money);
totalMoney += money;
}
else if( cmd == "report" ){
printf("%d\n", totalMoney);
}
}
}
return 0;
}