串结构练习——字符串连接
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
给定两个字符串string1和string2,将字符串string2连接在string1的后面,并将连接后的字符串输出。
连接后字符串长度不超过110。
Input
输入包含多组数据,每组测试数据包含两行,第一行代表string1,第二行代表string2。
Output
对于每组输入数据,对应输出连接后的字符串,每组输出占一行。
Sample Input
123 654 abs sfg
Sample Output
123654 abssfg
Hint
学了队列就用队列做做吧O(∩_∩)O哈哈~
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
int main()
{
char s1[120];
char s2[120];
queue<char>q;
while(cin>>s1>>s2)
{
int n1;
n1=strlen(s1);
int n2;
n2=strlen(s2);
for(int i=0; i<n1; i++)
q.push(s1[i]);
for(int i=0; i<n2; i++)
q.push(s2[i]);
while(!q.empty())
{
cout<<q.front();
q.pop();
}
cout<<endl;
}
return 0;
}