Supppose I have an integer= 0123456789101112 . Now This Integer Can be Converted into String By stringstream class
Here is Code in C++
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
string s;
stringstream st;
for(i=0;i<=12;i++)
{
st<<i;
}
s=st.str();
cout<<s<<endl;
return 0;
}
Code To Find Desire Position String :
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
string s;
// cout<<"Enter Position"<<endl;
cin>>n;
stringstream st;
for(i=0;i<=1000;i++)
{
st<<i;
}
s=st.str();
cout<<s[n]<<endl;
return 0;
}
Related Problem : Codeforces 352 Div 2 A
0 comments:
Post a Comment