木子 @ 2017-10-03 21:06:57
已ac
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
int a,i,j;
bool b;
int main()
{
queue<int>q;
cin>>a;
if(a<0)
b=true;
a=abs(a);
do
{
i=a%10;
q.push(i);
a/=10;
}while(a!=0);
j=q.size();
for(int c=0;c<j;c++)
{
q.push(q.front());
q.pop();
}
for(;;)
{
if(q.front())
break;
q.pop();
}
if(b)
cout<<"-";
do
{
cout<<q.front();
q.pop();
}while(q.empty()!=1);
return 0;
}
by iphone_X @ 2017-10-04 10:58:49
额,对于各位dalao的题解,我深表佩服,本蒟蒻也来发个题解:
#include<iostream>
#include<cstdlib>
using namespace std;
int a,b,zf;
int main()
{
cin>>a;
if(a<0) zf=-1;
a=abs(a);
while(a>0){
b=b*10+a%10;
a/=10;
}
cout<<b*zf;
}
精简短小