(c++ ) 编写一程序实现输入行的逆序输出

来源:百度知道 编辑:UC知道 时间:2024/07/01 06:42:01
编写一程序实现输入 行的逆序输出...
(提示:采用字符串的堆栈类,并使用输入流的getline()成员函数读取一行输入)各位高手帮帮忙啊!!!万分感谢!
不好意思啊..我想要的是行的逆序输出!
比如说输入:
abs
thwu
efuhfv
输出:
efuhfv
thwu
abs

不是很严格的按照你的提示可以么?
#include <stdio.h>
#include <string.h>
#include <iostream.h>

char *converse(char *str)
{
int len=strlen(str);
char *newStr=new char [len+1];
int j=0;
int i=len-1;
while (i>=0)
{
newStr[j++]=str[i--];
}
newStr[j]='\0';
return newStr;
}
void main()
{
char str[1024];
cin.getline(str,80);

char *p=converse(str);

cout<<p;

delete p;
}