11 个解决方案
#1
好像没有,我一般是使用通用算法中的reverse
std:;reverse(mystring.begin(), mystring.end());
std:;reverse(mystring.begin(), mystring.end());
#2
好像没有,我一般是使用通用算法中的reverse
std:;reverse(mystring.begin(), mystring.end());
std:;reverse(mystring.begin(), mystring.end());
#3
好像没有,我一般是使用通用算法中的reverse
std:;reverse(mystring.begin(), mystring.end());
std:;reverse(mystring.begin(), mystring.end());
#4
同意楼上的
template <class BidirectionalIterator>
void reverse(BidirectionalIterator first, BidirectionalIterator last);
Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)).
Defined in the standard header algorithm
template <class BidirectionalIterator>
void reverse(BidirectionalIterator first, BidirectionalIterator last);
Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)).
Defined in the standard header algorithm
#5
#include <iostream>
#include <string>
using namespace std;
void main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
}
//为什么会在运行时出错?
#include <string>
using namespace std;
void main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
}
//为什么会在运行时出错?
#6
ADD:
#include <algorithm>
#include <algorithm>
#7
还是出错!
#8
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
#9
用上了system(...),请再加上#include <cstdlib>
#10
用上了system(...),请再加上#include <cstdlib>
#11
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
再不对,说明你的编译器有问题了
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
再不对,说明你的编译器有问题了
#1
好像没有,我一般是使用通用算法中的reverse
std:;reverse(mystring.begin(), mystring.end());
std:;reverse(mystring.begin(), mystring.end());
#2
好像没有,我一般是使用通用算法中的reverse
std:;reverse(mystring.begin(), mystring.end());
std:;reverse(mystring.begin(), mystring.end());
#3
好像没有,我一般是使用通用算法中的reverse
std:;reverse(mystring.begin(), mystring.end());
std:;reverse(mystring.begin(), mystring.end());
#4
同意楼上的
template <class BidirectionalIterator>
void reverse(BidirectionalIterator first, BidirectionalIterator last);
Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)).
Defined in the standard header algorithm
template <class BidirectionalIterator>
void reverse(BidirectionalIterator first, BidirectionalIterator last);
Reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2), it exchanges *(first + i) and *(last - (i + 1)).
Defined in the standard header algorithm
#5
#include <iostream>
#include <string>
using namespace std;
void main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
}
//为什么会在运行时出错?
#include <string>
using namespace std;
void main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
}
//为什么会在运行时出错?
#6
ADD:
#include <algorithm>
#include <algorithm>
#7
还是出错!
#8
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
#9
用上了system(...),请再加上#include <cstdlib>
#10
用上了system(...),请再加上#include <cstdlib>
#11
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
再不对,说明你的编译器有问题了
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main()
{
string s="123456";
reverse(s.begin(),s.end());
cout<<s;
system("pause");
return 0;
}
再不对,说明你的编译器有问题了