#include <sstream>
using namespace std;
int out0(int);
int x,number;
string out_string="";
stringstream sl;
int main()
{
while(cin>>x)
{
number = out0(x);
sl<<number;
sl>>out_string;
char out0[100];
itoa(number,out0,10);
for(int i=out_string.length()-1;i>=0;i--)
out_string = out_string+out0[i];
cout<<out_string;
}
}
int out0(int x)
{
while(x%10==0)
{
x=x/10;
}
return x;
}
/*假如我cin>>955996
但他卻cout<<955996699559
why??如何解決!!!
*/
#include
using namespace std;
int out0(int);
int x,number;
string out_string="";
stringstream sl;
int main()
{
while(cin>>x)
{
number = out0(x);
sl<<number;
sl>>out_string;
char out0[100];
itoa(number,out0,10);
for(int i=out_string.length()-1;i>=0;i--)
out_string = out_string+out0[i];
cout<<out_string;
}
}
int out0(int x)
{
while(x%10==0)
{
x=x/10;
}
return x;
}
/*假如我cin>>955996
但他卻cout<<955996699559
why??如何解決!!!
*/
sl>>out_string; 你的 out_strig 字串己經有值了
你後面 out_string = out_string+out0[i];
就是在 out_string 後面加上 out0[i] << 這裡發生問題的 , 在原本的字串後面一直加上新的字串 ,所以會錯
若你要用這方法. 那麼輸出答案時就用新的字串來讀入 , 不要用 out_string 就行了