- 数字反转:
(把数字前面的0自动过滤)
int n;
cin >> n;
int r = 0;
while ( n )
{
r = r * 10 + ( n % 10);
n /= 10;
}
cout << r;
- 最大公约数:
int MaxCommonFactor( int a, int b)
{
int c;
if(a<=0||b<=0)
return -1;
while(b!=0)
{
c=a%b;
a=b;
b=c;
}
return a;
}