您的位置:首页 > 其它

UVA - 10361 Automatic Poetry

2016-07-13 16:31 465 查看

UVA - 10361 Automatic Poetry

题目大意:给出两个序列,第一个 s1s3s5,第二个 S…。输出两个序列,第一个删除括号,即 s1s2s3s4s5,第二个将 s2 与 s4 交换位置后替换…,即 Ss4s3s2s5。

解题思路:读入两个序列,以括号为分界分别赋值给 5 个字符串,按需求输出。

#include<iostream>
#include<cstring>

char s[10][10000];
int main(){
int cc;
scanf("%d",&cc);
char temp[10000];
char temp2[10000];
char t[4]="...";
getchar();
while(cc--)
{
memset(temp,0,sizeof(temp));
memset(temp2,0,sizeof(temp2));
memset(s,0,sizeof(s));
gets(temp);
gets(temp2);
int i=0;
int j=0;
for(i ;temp[i] !='<' ;i++)
s[0][j++]=temp[i];
i++;
j=0;

for(i ;temp[i] !='>' ;i++)
s[1][j++]=temp[i];
j=0;
i++;

for(i ;temp[i] !='<' ;i++)
s[2][j++]=temp[i];
j=0;
i++;
for(i ;temp[i] !='>' ;i++)
s[3][j++]=temp[i];
j=0;
i++;
for(i ; i<strlen(temp);i++)
s[4][j++]=temp[i];
j=0;
for(i = 0; temp2[i]!='.';i++)
s[5][j++]=temp2[i];
printf("%s%s%s%s%s\n",s[0],s[1],s[2],s[3],s[4]);
printf("%s%s%s%s%s\n",s[5],s[3],s[2],s[1],s[4]);

}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: