用栈实现带有空格或者逗号的字符串的反转
//字符串反转,整型数字反转
#include <iostream>
#include <string>
#include<stack>
using namespace std;
int main()
{
cout << "请输入一行字符串:" << endl;
string str;
getline(cin, str);
int L = str.length();
const char* ss = str.c_str();
stack<char> s;
int i = 0;
while (L--)
{
s.push(str[i++]);
}
while(!s.empty())
{
cout << s.top();
s.pop();
}
cout << endl;
return 0;
}