测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A41077. 字符逆序

填空题 较易

题目描述

字符逆序

题目描述

将一个字符串str的内容颠倒过来,并输出。str的长度不超过100个字符。

输入格式

输入包括一行。 第一行输入的字符串。

输出格式

输出转换好的逆序字符串。

样例输入

I am a student

样例输出

tneduts a ma I

参考答案

#include <stdio.h> #include <string.h> int main(void) { char c; char output[100]; int index = 0; int i = 0; while ((c = getchar()) != EOF && c != '\n' && i <= 100) { output[index++] = c; i++; } //output[index] = '\0'; for (i = index - 1; i >= 0; i--) { putchar(output[i]); } //putchar('\n'); return 0; }
上一题 下一题