题目1055:数组逆置

来源:互联网 发布:朱丹 知乎 编辑:程序博客网 时间:2024/05/16 06:46
题目描述:

输入一个字符串,长度小于等于200,然后将数组逆置输出。

输入:

测试数据有多组,每组输入一个字符串。

输出:

对于每组输入,请输出逆置后的结果。

样例输入:
hdssg
样例输出:
gssdh
来源:

2011年哈尔滨工业大学计算机研究生机试真题



#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){    int m=0;    char *a=(char *)malloc(sizeof(char));    while(scanf("%s",a)!=EOF)    {        m=strlen(a);        while(m)        {            m--;            printf("%C",a[m]);        }        printf("\n");    }    return 0; }/**************************************************************    Problem: 1055    Language: C    Result: Accepted    Time:0 ms    Memory:912 kb****************************************************************/



0 0