level 1
比如输入 i love you,输出you love i
请高人解答,希望是可以运行的代码
2011年03月21日 08点03分
1
level 1
我的想法是首先全部逆置一遍,然后设置两个参数,遍历字符串,遇到空格那么就再局部逆置,但是因为很久没有写c的东西了,所以一些参数的调用和函数忘记了,所以希望有人能解答一下
2011年03月21日 08点03分
2
level 7
#include <string>
#include <iostream>
using namespace std;
int main()
{
string str;
getline(cin,str);
for(int i = str.size() - 1; str.c_str()[i] != '\0' && i >= 0 ;i--)
{
cout<<str.c_str()[i];
}
return 0;
}
2013年06月06日 07点06分
4
level 1
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main(int argc, char *argv[]){
stack<string> sstack;
string str;
// read words and save into Stack-Object
cout << "Enter some words(Ctrl + Z to end) :" << endl;
while(cin >> str){
sstack.push(str);
}
// get the words from sstack in reverse
cout << "Elements of Stack: " << endl;
for(stack<string>::size_type sz = sstack.size();
sstack.empty() == false; --sz){
str = sstack.top();
cout << str;
sstack.pop();
}
return 0;
}
2013年06月17日 05点06分
6
一定要用 C 么? C++ 行不?
2013年06月17日 05点06分
level 12
//这是c++代码
#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<string> L;
int main()
{
string a;
while (cin>>a)L.push_back(a);
for (vector<string>::reverse_iterator it=L.rbegin();it!=L.rend();++it)
cout<<*it<<' ';
}
2013年06月17日 12点06分
7