std::reverse
C++ stringstream介绍,使用方法与例子
#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#pragma warning(disable:4996)
using namespace std;
class Solution {
public:
int reverse(int x) {
long result;
string ex = to_string(x);
string reverse;
int pos = ex.find_first_not_of("-");
std::reverse(ex.begin() + pos, ex.end());
stringstream out(ex);
out >> result;
if (result > INT_MAX || result < INT_MIN)
return 0;
return result;
}
};
void main()
{
Solution SS;
cout<<SS.reverse(-1233);
}
C++ 判断字符串是否全是数字
sort在#include < algorithm>和using namespace std;
C++中set的用法