这道题目酝酿了很久了..
一开始在英语课上苦逼地用手机看,但是用手机看
du bist
bu dist
中间是没有空格的..于是就为了这个空格纠结了一节课╮(╯▽╰)╭昨晚用电脑看到有空格后就开始写..可是思路混乱,写到十一点写不下去了...于是就被拖到了今天.
题目很简单,扫描到'<'便开始存入s2,直到'>' ,以此类推.
坑爹的是复制输入数据的时候少了最后的三个点,于是就悲剧了...看了一遍又一遍一直看不出哪里错了..TAT
不过这题也算是我第一道一次AC的题目了O(∩_∩)O
#include <stdio.h>
#include <string.h>
char word[200];
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//先输出去掉括号的句子.
int T;
scanf("%d*c",&T);
getchar();
while (T--)
{
int i = 0,j;
char s2[100],s3[100],s4[100],s5[100];
//bool first = true;
//fgets(word,200,stdin);
gets(word);
int len = strlen(word);
//puts(word);
for (i = 0; i < len; i++)
{
if (word[i] == '<' || word[i] == '>')
continue;
printf("%c",word[i]);
}
printf("\n");
//接下来读取s2,s3,s4,s5;
for (i = 0; i < len; i++)
{
if (word[i] == '<')
{
i++;
for (j = 0; word[i] != '>'; i++)
s2[j++] = word[i];
s2[j] = '\0'; //此时word[i] = '>';
i++;
//接下来扫描s3:
for (j = 0; word[i] != '<'; i++)
s3[j++] = word[i];
s3[j] = '\0'; //此时word[i] = '<';
i++;
for (j = 0; word[i] != '>'; i++)
{
s4[j++] = word[i];
}
s4[j] = '\0';
i++;
for (j = 0; i < len; i++)
s5[j++] = word[i];
s5[j] = '\0';
}
}
//输出第二句.
memset(word,0,200);
fgets(word,200,stdin);
for (i = 0; word[i] != '.'; i++) //扫描到 . 处;
printf("%c",word[i]);
printf("%s%s%s%s\n",s4,s3,s2,s5);
}
return 0;
}