1111: 单词调换位置
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 216 Solved: 101
[Submit][Status][Web Board]
Description
将用逗号隔开的两个英语单词交换位置输出
Input
一行以逗号隔开的两个单词
Output
将两个单词交换后输出
Sample Input
abc,de
Sample Output
de,abc
AC代码:
#include<cstdio>
#include<cstring>
const int N = 1000 + 10;
char s[N];
int main(){int len, t;bool flag = true;scanf("%s", s + 1);len = strlen(s + 1);for(int i = 1; i <= len; i++){if(s[i] == ','){flag = false;continue;}if(!flag) printf("%c", s[i]);}printf(",");for(int i = 1; ;i++){if(s[i] == ',') break;printf("%c", s[i]);}return 0;
}