ZOJ 1151 Word Reversal
来源:互联网 发布:巨灵新闻数据库 编辑:程序博客网 时间:2024/05/18 00:17
For each list of words, output a line with each word reversed without changing the order of the words.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
Input
You will be given a number of test cases. The first line contains a positive integer indicating the number of cases to follow. Each case is given on a line containing a list of words separated by one space, and each word contains only uppercase and lowercase letters.
Output
For each test case, print the output on one line.
Sample Input
1
3
I am happy today
To be or not to be
I want to win the practice contest
Sample Output
I ma yppah yadot
oT eb ro ton ot eb
I tnaw ot niw eht ecitcarp tsetnoc
题意:就是把输入的每个单词反转。
思路:就是一个个读入,一旦碰到空格输出,碰到回车,换行。
代码:
#include <stdio.h>
int main()
{
char a[100],c;
int i,j,n,m;
scanf("%d",&n);
while(n--){
scanf("%d\n",&m);
for(i=0;i<m;i++)
{
j=0;
while((c=getchar())!=EOF)
{
if(c==' '||c=='\n')
{
while(j--)printf("%c",a[j]);
printf("%c",c);
if(c=='\n')
break;
j=0;
}
else
a[j++]=c;
}
}
if(n!=0)
printf("\n");
}
return 0;
}
- zoj 1151 Word Reversal
- ZOJ 1151 Word Reversal
- ZOJ 1151 Word Reversal
- zoj 1151 Word Reversal
- zoj 1151 Word Reversal
- ZOJ 1151 Word Reversal
- ZOJ 1151: Word Reversal
- ZOJ 1151 Word Reversal
- ZOJ 1151 Word Reversal
- zoj 1151 Word Reversal
- zoj 1151 Word Reversal
- zoj 1151 Word Reversal
- ZOJ 1151 Word Reversal
- php - zoj 1151 Word Reversal
- zoj 1151 Word Reversal-------------输入输出超时
- ZOJ Problem Set - 1151 Word Reversal
- ZOJ-1151 Word Reversal,栈的解法
- ZOJ Problem Set - 1151 Word Reversal
- 寻找丑数
- Xen Cloud Platform 系列:XenCenter 安装
- VS2010的智能提示没有了的可能原因
- linux chkconfig 使用说明
- C无符号数和有符号数探讨
- ZOJ 1151 Word Reversal
- JSP+Servlet(最简单的例子)
- Android TabActivity 按键响应
- innerHTML
- logcat 源码
- 小问题 one of its dependencies
- 深入浅出设计模式笔记之五:适配器模式
- java Socket通信(一)
- ORACLE 产生随机数:DBMS_RANDOM