#17675: 給延平的同仁 c++ AC


089487 (089487)

學校 : 國立臺灣師範大學附屬高級中學
編號 : 82069
來源 : [220.130.10.185]
最後登入時間 :
2024-04-01 11:16:18
d614. 簡易加法運算 -- 葆葆 | From: [111.71.123.100] | 發表日期 : 2019-05-04 16:07

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,b;
int r,t;
char c;
long long int num,k;
cin>>t;
c=cin.get();
for(int g=0;g<t;g++)
{
getline(cin,s);
num=0,r=0;
stringstream ss(s);
while(ss>>k)
{
num+=k;
ss>>b;
//cout<<b<<endl;
}
cout<<num<<endl;
}

}

AC (9ms, 316KB)
 
#17676: Re:給延平的同仁 c++ AC


ufve0704 (爬 我爬 我爬爬爬 有排行榜這種東西就是要爬 爬過我上面的那...)

學校 : 臺北市私立延平高級中學
編號 : 83268
來源 : [203.72.178.1]
最後登入時間 :
2023-10-30 13:02:50
d614. 簡易加法運算 -- 葆葆 | From: [114.42.215.64] | 發表日期 : 2019-05-04 16:10

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,b;
int r,t;
char c;
long long int num,k;
cin>>t;
c=cin.get();
for(int g=0;g<t;g++)
{
getline(cin,s);
num=0,r=0;
stringstream ss(s);
while(ss>>k)
{
num+=k;
ss>>b;
//cout<<b<<endl;
}
cout<<num<<endl;
}

}

AC (9ms, 316KB)
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
cin.tie(0);
ios::sync_with_stdio(false);
string a;
long long int b,c,d;
cin>>c;
getline(cin,a);
while(c--){
b=0;
d=0;
getline(cin,a);
for(int e=0;e<a.size()+1;e++){
if(a[e]>='0'&&a[e]<='9')
d=d*10+int(a[e])-48;
else{
b=d+b;
d=0;
}
}
cout<<b<<endl;
}
}

AC (3ms, 356KB)

醬更快XD

 
ZeroJudge Forum