//输入指定长度数组
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int n = 0;
    cin>>n;
    vector<int>res(n);
    for (int i = 0; i < n; i++)
    {
        cin >> res[i];
    }
    cout << endl;
    return 0;
    system("pause");
}

 

//键盘输入任意长度的数组
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    vector<int>nums;
    int num = 0;
    do {
        cin >> num;
        nums.push_back(num);
    } while (getchar() != '\n');
   
    for (int  i = 0; i < nums.size(); i++)
    {
        cout << nums[i];
    }
    cout << endl;
    system("pause");
    return 0;
}

  

//键盘输入字符串类型的整数,然后将其输出数组
#include<iostream>
#include<vector>
#include<string>
#include<sstream>


using namespace std;

int main()
{
    string str, temp;
    getline(cin, str);
    int i = 0;
    vector<int>p;
    stringstream input(str);
    while (input>>i)
    {
        p.push_back(i);
    }
    for (int i = 0; i < p.size(); i++)
    {
        cout << p[i];
    }
    cout << endl;
    system("pause");
    return 0;
}

  

//键盘输入二维数组
#include<iostream>
#include<vector>
#include<string>
#include<sstream>


using namespace std;

int main()
{
    int x = 0;
    vector<vector<int>>vec;
    vector<int>v;
    while (cin>>x)
    {
        v.push_back(x);
        if (cin.get() == '\n')
        {
            vec.push_back(v);
            v.clear();
        }
        if (cin.peek() == '\n')
        {
            vec.push_back(v);
            break;
        }
    }
    for (int i = 0; i < vec.size(); i++)
    {
        for (int j = 0; j < v.size(); j++)
        {
            cout << vec[i][j] << ' ';
        }
    }
    system("pause");
    return 0;
}

  

int n, m;
	while (cin >> n >> m)
	{
	    vector<vector<int>> data(n, vector<int>(m));
	    int sum = 0;
	    for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)cin >> data[i][j];

  

 

 

 

------------恢复内容开始------------

链接:https://ac.nowcoder.com/acm/contest/5647/A
来源:牛客网

输入描述:

输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据包括多组。

输出描述:

输出a+b的结果
示例1

输入

复制
1 5
10 20

输出

复制
6
30


#include<iostream>
using namespace std;

int main(){
    int a,b;
    while(cin>>a>>b){
        cout<<a+b<<endl;
    }
    return 0;
}
#include<iostream>
using namespace std;

int main(){
    int a,b;
    while(scanf("%d %d", &a ,&b)!=EOF){
        printf("%d\n",a+b);
    }
    return 0;
}

  

 

输入描述:

输入第一行包括一个数据组数t(1 <= t <= 100)
接下来每行包括两个正整数a,b(1 <= a, b <= 10^9)

输出描述:

输出a+b的结果
示例1

输入

复制
2
1 5
10 20

输出

复制
6
30


#include<iostream>
using namespace std;

int main(){
    int t,a,b;
    cin>>t;
    while(t>0)
    {
       while(t--)
       {
           cin>>a>>b;
           cout<<a+b<<endl;
       }
    }
    return 0;
}
#include<iostream>
using namespace std;

int main()
{
    int t,a,b;
    scanf("%d",&t);
    for(int i=0;i<t;i++)
    {
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);
    }
    return 0;
}

链接:https://ac.nowcoder.com/acm/contest/5647/C
来源:牛客网

输入描述:

输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据有多组, 如果输入为0 0则结束输入

输出描述:

输出a+b的结果
示例1

输入

1 5
10 20
0 0

输出

6
30
#include<iostream>
using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b){
        if(a==0&& b==0) break;
        cout<<a+b<<endl;
    }
    return 0;
}
#include<iostream>
using namespace std;

int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)){
        if(a==0 && b==0) break;
        printf("%d\n",a+b);
    }
    
    return 0;
}
 

链接:https://ac.nowcoder.com/acm/contest/5647/D
来源:牛客网

输入描述:

输入数据包括多组。
每组数据一行,每行的第一个整数为整数的个数n(1 <= n <= 100), n为0的时候结束输入。
接下来n个正整数,即需要求和的每个正整数。

输出描述:

每组数据输出求和的结果
示例1

输入

4 1 2 3 4
5 1 2 3 4 5
0

输出

10
15
#include<iostream>
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0) break;
        int m,sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>m;
            sum +=m;
        }
        cout<<sum<<endl;
    }
    return 0;
}
#include<iostream>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n) != EOF)
    {
        if(n==0) break;
        int m,sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&m);
            sum +=m;
        }
        printf("%d\n",sum);
    }
    return 0;
}

链接:https://ac.nowcoder.com/acm/contest/5647/E
来源:牛客网

输入描述:

输入的第一行包括一个正整数t(1 <= t <= 100), 表示数据组数。
接下来t行, 每行一组数据。
每行的第一个整数为整数的个数n(1 <= n <= 100)。
接下来n个正整数, 即需要求和的每个正整数。

输出描述:

每组数据输出求和的结果
示例1

输入

2
4 1 2 3 4
5 1 2 3 4 5

输出

10
15
#include<iostream>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0 && t<=100)
    {
        int n;
        cin>>n;
        int a,sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            sum +=a;
        }
        t--;
        cout<<sum<<endl;
    }
    return 0;
}

#include<iostream>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t>0 && t<=100)
    {
        int n,a,sum=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a);
            sum +=a;
        }
        printf("%d\n",sum);
        t--;
    }
    return 0;
}

输入描述:

输入数据有多组, 每行表示一组输入数据。
每行的第一个整数为整数的个数n(1 <= n <= 100)。
接下来n个正整数, 即需要求和的每个正整数。

输出描述:

每组数据输出求和的结果
示例1

输入

4 1 2 3 4
5 1 2 3 4 5

输出

10
15
#include<iostream>
using namespace std;

int main(){
    int n;
    while(cin>>n){
        int a,sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            sum +=a;
        }
        cout<<sum<<endl;
    }
    return 0;
}
#include<iostream>
using namespace std;

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int a,sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a);
            sum +=a;
        }
        printf("%d\n",sum);
    }
    return 0;
}

链接:https://ac.nowcoder.com/acm/contest/5647/G
来源:牛客网

输入描述:

输入数据有多组, 每行表示一组输入数据。

每行不定有n个整数,空格隔开。(1 <= n <= 100)。

输出描述:

每组数据输出求和的结果
示例1

输入

1 2 3
4 5
0 0 0 0 0

输出

6
9
0
#include<iostream>
using namespace std;

int main(){
    int n;
    while(cin>>n)
    {
        int sum=n;
        while(cin.get() !='\n')
        {
            cin>>n;
            sum +=n;
        }
        cout<<sum<<endl;
    }
    return 0;
}
#include<iostream>
using namespace std;

int main(){
    int n,sum=0;
    while(scanf("%d",&n)!=EOF)
    {
        sum +=n;
        if(getchar()=='\n')
        {
            printf("%d\n",sum);
            sum=0;
        }
    }
}

链接:https://ac.nowcoder.com/acm/contest/5647/H
来源:牛客网

输入描述:

输入有两行,第一行n

第二行是n个空格隔开的字符串

输出描述:

输出一行排序后的字符串,空格隔开,无结尾空格
示例1

输入

5
c d a bb e

输出

a bb c d e
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    vector<string>strs;
    while(cin>>s)
    {
        strs.push_back(s);
        
        if(cin.get()=='\n')
        {
            sort(strs.begin(),strs.end());
            for(int i=0;i<strs.size()-1;i++)
            {
                cout<<strs[i]<<' ';
            }
            cout<<strs[strs.size()-1]<<endl;
            strs.clear();
        }
    }
    
}

 

链接:https://ac.nowcoder.com/acm/contest/5647/I
来源:牛客网

输入描述:

多个测试用例,每个测试用例一行。

每行通过空格隔开,有n个字符,n<100

输出描述:

对于每组测试用例,输出一行排序过的字符串,每个字符串通过空格隔开
示例1

输入

a c bb
f dddd
nowcoder

输出

a bb c
dddd f
nowcoder
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

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();i++)
            {
                cout<<str[i]<<' ';
            }
            cout<<endl;
            str.clear();
        }
    }
    return 0;
}

 

链接:https://ac.nowcoder.com/acm/contest/5647/J
来源:牛客网

输入描述:

多个测试用例,每个测试用例一行。
每行通过,隔开,有n个字符,n<100

输出描述:

对于每组用例输出一行排序后的字符串,用','隔开,无结尾空格
示例1

输入

a,c,bb
f,dddd
nowcoder

输出

a,bb,c
dddd,f
nowcoder

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{
    string s;
    while(getline(cin,s,'\n'))
    {
        string temp;
        vector<string> res;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]!=',')
            {
                temp.push_back(s[i]);
            }
            else{
                res.push_back(temp);
                temp.clear();
            }
        }
        res.push_back(temp);
        sort(res.begin(), res.end());
        for(int i=0;i<res.size();i++)
        {
            cout<<res[i];
            if(i==res.size()-1) {
                cout<<endl;
            }
            else {
                cout<<',';
            }
        }
        
    }
    return 0;
}