若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1627: Reverse Text

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,199

题目描述

In most languages, text is written from left to right. However, there are other languages where text is read and written from right to left. As a first step towards a program that automatically translates from a left-to-right language into a right-to-left language and back, you are to write a program that changes the direction of a given text.

输入

The input contains several test cases. The first line contains an integer specifying the number of test cases. Each test case consists of a single line of text which contains at most 70 characters. However, the newline character at the end of each line is not considered to be part of the line.

输出

For each test case, print a line containing the characters of the input line in reverse order.

样例输入

3
Frankly, I don't think we'll make much
money out of this scheme.
madam I'm adam

样例输出

hcum ekam ll'ew kniht t'nod I ,ylknarF
.emehcs siht fo tuo yenom
mada m'I madam

参考代码

#include"stdio.h"
#include"string.h"
int main() 
{
    int i,j,n,m;
    char c[81],a;
    scanf("%dn",&n);
    for(i=0;i<n;i++){
        gets(c);
        m=strlen(c);
        for(j=0;j<m/2;j++){
            a=c[j];
            c[j]=c[m-1-j];
            c[m-1-j]=a;
        }
        puts(c);
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip Dreams孤独患者 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist