首页 > 代码库 > to_string()的应用

to_string()的应用

作用是将数字转化为字符串

#include<iostream>#include<cmath>#include<algorithm>#include<cstring>#include<string>#include<stack>#include<queue>#include<map>#include<cstdlib>#include<set>#include<ctime>#include<vector>#include<cstdio>#include<list>using namespace std;typedef long long ll;int INF=2147483647;int inf=-2147483648;#define read(x) scanf("%d",&x);#define fo(i,n) for(int i=1;i<=(n);i++)#define me(a) memset(a,0,sizeof(a));#define one(x) cout<<(x)<<endl;#define two(a,b) cout<<(a)<<" "<<(b)<<endl;int main(){    int n;    string s;    for(int i=1;i<=1000;i++)    {        s+=to_string(i);    }    cin>>n;    one(s[n-1]);    return 0;}

 

to_string()的应用