int和string之间的转换
#include<cstring> #include<algorithm> #include<stdio.h> #include<iostream> #include<sstream> #include<string> #define ll long long #define inf 0x3f3f3f3f using namespace std; string itos(int i)///int 转 string { stringstream ss;///中转站 ss<<i; int b=55555; ss<<b;///按字符形式接在后面 string s; ss>>s;///一次性传给s return s; } int stoi(string s)///string 转 int { stringstream ss; ss<<s; int res; ss>>res; return res; } int main() { int a; string s; a=5201314; s="10086"; cout<<itos(a)<<endl; cout<<stoi(s)<<endl; return 0; }