SOJ.Concatenation and substring

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;
    }
} 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值