数字转字符串
#include <sstream>
#Include <string>
string num2str(int i)
{
stringstream ss;
ss<<i;
return ss.str();
}
字符串转数字:
int str2num(string s)
{
int num;
stringstream ss(s);
ss>>num;
return num;
}
String 大小写转换:
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;
int main()
{
string s = "Clare";
// toUpper
transform(s.begin(), s.end(), s.begin(), ::toupper);
// toLower
//transform(s.begin(),s.end(),s.begin(), ::tolower);
cout << s << endl;
}
bitset -> string
string s=c.to_string<char,char_traits<char>,allocator<char> >();
对拍
#include<iostream>
#include<cstdio>
using namespace std;
int Cnt;
int main()
{
while(1){
printf("%d\n",++Cnt);
system("Rand >c.in");
system("Test <c.in >c.out");
system("Bl <c.in >s.out");
if(system("fc c.out s.out"))
{system("pause");break;}
}
return 0;
}