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

PROGRAMMING:Static local variable analysis code

Luz5年前 (2021-05-10)题库419
```
Static local variable program example, analysis code
#include
long next(long n){
//static long s=0;
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 1 is 8.
Times of 1 is 4.
Times of 1 is 2.
Times of 1 is 1.
```







answer:If there is no answer, please comment