UVA 10361 Automatic Poetry

16 篇文章 0 订阅

这道题目酝酿了很久了..

一开始在英语课上苦逼地用手机看,但是用手机看

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值