2016年11月5日 星期六

TIOJ 1179 - 社費.沒繳

http://tioj.infor.org/problems/1179

微煩人的case題而已(?)



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
#include<sstream>
using namespace std;
string s;
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    while(getline(cin,s)){
        if(s[0]=='0')break;
        stringstream ss;
        ss<<s;
        int a,tot=0,cnt=0,fst=0;
        while(ss>>a && a){
            tot+=a;
            cnt++;
            if(!fst)fst=a;
        }
        cout<<fst<<" "<<cnt<<" "<<tot<<'\n';
    }
}

沒有留言:

張貼留言