小G的循环
Time Limit: 2000/1000ms (Java/Others)
Problem Description:
一回生,二回熟,三回就腻,小G用for,while循环用得太多了,累觉不爱。于是自定义了一个循环,叫circle,形式如下:
void circle(int n)
{
n--;
if(n == 0)
return;
else
circle(n);
}
已知循环次数为该函数的调用次数,现在输入n(-2^31< =n< =2^31-1),求circle()的循环次数。
Output:
对于每组数据,输出circle()的循环次数。
Sample Output:
3
解题思路:考虑一下几种特殊情况,调用的次数即为循环的次数,水过!
AC代码:
1 #include<bits/stdc++.h>
2 using namespace std;
3 int main(){
4 int a;
5 while(cin>>a){
6 if(a==0)cout<<"4294967296"<<endl;
7 else printf("%u\n",a);//自动转化成无符号10进制整数
8 }
9 return 0;
10 }