-->
当前位置:首页 > 题库

PROGRAMMING:Example of static local variable program

Luz5年前 (2021-05-10)题库372
```
Static local variable program example, analysis code
#include
long next(long n){
static long s=0;
if(n%2==1) n=n*3+1;
else n=n/2;
s++;
printf("Times of %ld is %ld.\n",s,n);
return n;
}
int main(){
long n;
scanf("%ld",&n);
while(n!= 1){
n=next(n);
}
return 0;
}
```
###Input example:
```in
five
```
###Output example:
```out
Times of 1 is 16.
Times of 2 is 8.
Times of 3 is 4.
Times of 4 is 2.
Times of 5 is 1.
```







answer:If there is no answer, please comment