题目链接: https://ac.nowcoder.com/acm/contest/5646
A A+B(1)
题目描述
计算a+b
输入描述:
1
| 输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据包括多组。
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b; while(cin>>a>>b){ cout<<a+b<<endl; } return 0; }
|
B A+B(2)
题目描述
计算a+b
输入描述:
1 2
| 输入第一行包括一个数据组数t(1 <= t <= 100) 接下来每行包括两个正整数a,b(1 <= a, b <= 10^9)
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b,t; cin>>t; while(t--){ cin>>a>>b; cout<<a+b<<endl; } return 0; }
|
C A+B(3)
题目描述
计算a+b
输入描述:
1
| 输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据有多组, 如果输入为0 0则结束输入
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b; while(cin>>a>>b && (a!=0 &&b!=0)) cout<<a+b<<endl; return 0; }
|
D A+B(4)
题目描述
计算一系列数的和
输入描述:
1 2 3
| 输入数据包括多组。 每组数据一行,每行的第一个整数为整数的个数n(1 <= n <= 100), n为0的时候结束输入。 接下来n个正整数,即需要求和的每个正整数。
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b; while(cin>>a && a!=0){ int sum=0; for(int i=0;i<a;i++){ cin>>b; sum+=b; } cout<<sum<<endl; } return 0; }
|
E A+B(5)
题目描述
计算一系列数的和
输入描述:
1 2 3 4
| 输入的第一行包括一个正整数t(1 <= t <= 100), 表示数据组数。 接下来t行, 每行一组数据。 每行的第一个整数为整数的个数n(1 <= n <= 100)。 接下来n个正整数, 即需要求和的每个正整数。
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b,c,sum; cin>>a; while(a--){ cin>>b; int sum=0; for(int i=0;i<b;i++){ cin>>c; sum+=c; } cout<<sum<<endl; } return 0; }
|
F A+B(6)
题目描述
计算一系列数的和
输入描述:
1 2 3
| 输入数据有多组, 每行表示一组输入数据。 每行的第一个整数为整数的个数n(1 <= n <= 100)。 接下来n个正整数, 即需要求和的每个正整数。
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b; while(cin>>a){ int sum=0; for(int i=0;i<a;i++){ cin>>b; sum+=b; } cout<<sum<<endl; } return 0; }
|
G A+B(7)
题目描述
计算一系列数的和
输入描述:
1 2 3
| 输入数据有多组, 每行表示一组输入数据。
每行不定有n个整数,空格隔开。(1 <= n <= 100)。
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<bits/stdc++.h>
using namespace std;
int main(){ int a,b; int sum=0; while(cin>>a){ sum+=a; if(cin.get()=='\n'){ cout<<sum<<endl; sum=0; } } return 0; }
|
H 字符串排序(1)
题目描述
对输入的字符串进行排序后输出
输入描述:
1 2 3
| 输入有两行,第一行n
第二行是n个空格隔开的字符串
|
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include<bits/stdc++.h>
using namespace std;
int main(){ int t; cin>>t; string s; vector<string> st; for(int i=0;i<t;i++){ cin>>s; st.push_back(s); } sort(st.begin(),st.end()); for(int i=0;i<t;i++){ cout<<st[i]<<" "; } return 0; }
|
I 字符串排序(2)
题目描述
对输入的字符串进行排序后输出
输入描述:
1 2 3
| 多个测试用例,每个测试用例一行。
每行通过空格隔开,有n个字符,n<100
|
输出描述:
1
| 对于每组测试用例,输出一行排序过的字符串,每个字符串通过空格隔开
|
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include<bits/stdc++.h>
using namespace std;
int main(){ string s; vector<string> str; while(cin>>s){ str.push_back(s); if(cin.get() == '\n'){ sort(str.begin(),str.end()); for(int i = 0;i < str.size()-1;i++) cout<<str[i]<<" "; cout<<str[str.size()-1]<<endl; str.clear(); } } return 0; }
|
J 字符串排序(3)
题目描述
对输入的字符串进行排序后输出
输入描述:
1 2
| 多个测试用例,每个测试用例一行。 每行通过,隔开,有n个字符,n<100
|
输出描述:
1
| 对于每组用例输出一行排序后的字符串,用','隔开,无结尾空格
|
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include<bits/stdc++.h>
using namespace std;
int main(){ vector<string> str; string a,s; while(cin>>a){ stringstream ss(a); while(getline(ss,s,',')) str.push_back(s); sort(str.begin(),str.end()); for(int i=0;i<str.size()-1;i++) cout<<str[i]<<","; cout<<str[str.size()-1]<<endl; str.clear(); } return 0; }
|
K 自测本地通过提交为0
题目描述
每年前几场在线笔试编程题的时候,总有同学询问为什么我本地测试通过,自测也通过,提交代码系统却返回通过率0。
这不是系统的错,可能是因为
1.你对题目理解错了,你的代码只过了样例或你自己的数据
2.你的代码逻辑有问题,你的代码只过了样例或你自己的数据
总之就是你的代码只是过了样例和自测数据,后台的测试数据你根本不可见,要多自己思考。
这个题目如果你提交后通过率为0,又觉得自己代码是正确的,可以 点击查看 通过的代码
谨记:
当你笔试的时候怀疑系统或者题目数据有问题的时候请务必先怀疑自己的代码!
当你笔试的时候怀疑系统或者题目数据有问题的时候请务必先怀疑自己的代码!
请帮忙把这个练习专题发给你的朋友同学吧,感谢感谢
输入描述:
输出描述:
示例1
输入
输出
代码
1 2 3 4 5 6 7 8 9 10
| #include<bits/stdc++.h>
using namespace std;
int main(){ long a,b; while(cin>>a>>b) cout<<a+b<<endl; return 0; }
|