5 solutions

  • 0
    @ 2023-10-25 15:16:17
    #include<stdio.h>
    #include<math.h>
    #pragma warning(disable:4996) 
    int main()
    {
        int num = 0, temp;;
        scanf("%d", &num);
        while (num != 1)
        {
            temp = num;
            if (num % 2 != 0)
            {
                num *= 3;
                num++;
                printf("%d*3+1=%d\n",  temp ,num);
            }
            else
            {
                num /= 2;
                printf("%d/2=%d\n", temp, num);
            }
        }
        printf("End\n");
        return 0;
    }
    

    Information

    ID
    6752
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    422
    Accepted
    82
    Uploaded By