您的位置:首页 > 其它

hdu Text Reverse

2015-10-12 09:59 274 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062

单词翻转!

代码:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <iomanip>
#include <queue>
#include <stdlib.h>
using namespace std;

int main()
{
int n;
char a[1000];
while(~scanf("%d",&n)){
getchar();
while(n--){
gets(a);
int m=strlen(a);
int k=0,t=0,j,i;
for(i=0; i<=m; i++)
{
if(a[i]==' '||a[i]=='\0')
{
k=i;
for(j=k-1; j>=t; j--)
{
printf("%c",a[j]);
}
t=k+1;
if(a[i]==' ')
printf(" ");
}
}
printf("\n");
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: