[ZJ]a307: NOIP2011 1.数字反转
題目:
http://zerojudge.tw/ShowProblem?problemid=a307
----------------------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std ;
int main() {
long long int in0 ;
while (cin >>in0 ){
if(in0 < 0)
{
in0 = -in0;
printf("-");
}
if (in0==0 ){
cout << 0 ;
break;
}
while (in0%10==0&&in0>0){
in0/=10;
}
while (in0){
cout <<in0%10 ;
in0/=10 ;
}
cout <<endl ;
}
return 0;
}
http://zerojudge.tw/ShowProblem?problemid=a307
----------------------------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std ;
int main() {
long long int in0 ;
while (cin >>in0 ){
if(in0 < 0)
{
in0 = -in0;
printf("-");
}
if (in0==0 ){
cout << 0 ;
break;
}
while (in0%10==0&&in0>0){
in0/=10;
}
while (in0){
cout <<in0%10 ;
in0/=10 ;
}
cout <<endl ;
}
return 0;
}
留言
張貼留言