HDOJ 题目3456 Universal Oracle(模拟,水)

Universal Oracle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 586    Accepted Submission(s): 242


Problem Description
In computer science, an oracle is something that gives you the answer to a particular question. For this problem, you need to write an oracle that gives the answer to everything. But it's not as bad as it sounds; you know that 42 is the answer to life, the universe, and everything.
 

Input
The input consists of a single line of text with at most 1000 characters. This text will contain only well-formed English sentences. The only characters that will be found in the text are uppercase and lowercase letters, spaces, hyphens, apostrophes, commas, semicolons, periods, and question marks. Furthermore, each sentence begins with a single uppercase letter and ends with either a period or a question mark. Besides these locations, no other uppercase letters, periods, or question marks will appear in the sentence. Finally, every question (that is, a sentence that ends with a question mark) will begin with the phrase "What is..."
 

Output
For each question, print the answer, which replaces the "What" at the beginning with "Forty-two" and the question mark at the end with a period. Each answer should reside on its own line.
 

Sample Input
  
  
Let me ask you two questions. What is the answer to life? What is the answer to the universe?
 

Sample Output
  
  
Forty-two is the answer to life. Forty-two is the answer to the universe.
 

Source
 

Recommend
zhengfeng   |   We have carefully selected several similar problems for you:   2196  2242  1520  3454  3457 
 
有个坑,当开始是what 但是以.结尾时不用换,,还有刚开始没看清题,以为多组输入数据,写成while!=EOF型的一直超时,,,额,,水死了
ac代码
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100010];
	char *p,*m,*i,*j;
	gets(s);
	p=strstr(s,"What is");
	m=p;
	while(p)
	{
		
		for(i=p+4;;i++)
		{
			if(*i=='?')
			{
				printf("Forty-two");
				for(j=p+4;j<i;j++)
				{
					printf("%c",*j);
				}
				printf(".\n");
				break;
			}
			if(*i=='.')
				break;
		}
		p=strstr(i+1,"What is");
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值