标签:iostream 编程 namespace c++ 博客
Description
将一个字符串str的内容颠倒过来,并输出。str的长度不超过100个字符。
Input
输入包括一行。第一行输入的字符串。
Output
输出转换好的逆序字符串。
Sample Input
I am a student
SampleOutput
tneduts a ma I
代码如下:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int i=0;
char str[100];
gets(str);
while (i<100)
{
if (str[i]=='\0')
break;
i++;
}
for (i=i-1;i>=0;i--)
cout<<str[i];
return 0;
}
运行结果:
标签:iostream 编程 namespace c++ 博客
原文地址:http://blog.csdn.net/liuchang54/article/details/42346965