Concatenation and substring
|
时间限制:1秒
内存限制:256兆
题目描述
In this problem, you are required to concatenate given integers and letters into a string S, and output a substring of S. Note that you need to respectively sort the integers and letters first.
输入格式
There are multiple cases. For each case, the first line contains two integers n and m (1<=n, m<=100), which denote the number of integers and strings, respectively. Then the second line gives n integers and the third line gives m strings. The fourth line has two integers x and y denoting the starting and ending index of string S for generating the substring.
输出格式
The substring.
样例输入
3 21234 567 89xyz abcd8 9
样例输出
4a
提示
In the above sample, the string S is “895671234abcdxyz”. |
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
int a[1000];
string s[100];
int main()
{
int n,m;
while(cin >> n >> m)
{
stringstream ss;
for(int i=0;i<n;i++)
cin >> a[i];
for(int i=0;i<m;i++)
cin >> s[i];
int x,y;
cin >> x;
cin >> y;
sort(a,a+n);
sort(s,s+m);
for(int i=0;i<n;i++)
ss << a[i];
for(int i=0;i<m;i++)
ss << s[i];
string str = ss.str();
string sss = str.substr(x,y-x+1);
cout << sss << endl;
}
}