help me!!! please!!!
查看原帖
help me!!! please!!!
1620890
Srz_extreme楼主2024/12/18 21:40
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n); 
    int temp=n;
    int bb[1000];
    int i=1;//move seat
    int j;
    bb[0]=n;
    
    while(1){
        if(temp%2!=0){
            temp=temp*3+1;
            bb[i]=temp;
        }else{
            temp=temp/2;
            bb[i]=temp;
        }
        i++;
        
        if(temp==1){
            break;
        }
    }
    j=i;
    for(int i=0;i<j/2;i++){
        int t=bb[i];
        bb[i]=bb[j-1-i];
        bb[j-1-i]=t;
    }
    for(int h=0;h<j;h++){
        printf("%d ",bb[h]);
        //printf(" ");
    }
}
2024/12/18 21:40
加载中...