| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 436 人关注过本帖
标题:字符反串问题
取消只看楼主 加入收藏
wbq777
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2011-6-24
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:0 
字符反串问题
Problem Description
Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.

Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.

Output
For each test case, you should output the text which is processed.
 
Sample Input
3
olleh !dlrow
m'I morf .udh
I ekil .mca
 
Sample Output
hello world!
I'm from hdu.
I like acm.
题目意思很简单,看下范例就知道了。。问题就是我不会、我编了个狗P不通的程序。。。很纠结!
本人程序:
#include"stdio.h"
#include"string.h"
int main()
{
    int i,a,n,j;
    char c[1000],c1[1000],d[2];
    scanf("%d",&n);
    gets(d);
    i=0;
    while(i<n)
    {
        a=0;
        gets(c);
        for(i=0;c[i]!='\0';i++)
        {
            if(c[i]==' ')
            {
                for(j=a;j<=i;j++)
                {
                    c1[j]=c1[i-j];
                }
                c1[j]=' ';
                a=j;   
            }
        }
        puts(c1);
    }
}
搜索更多相关主题的帖子: single several written number should 
2011-08-10 16:19
快速回复:字符反串问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024110 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved