Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6.  
  7.    
  8. int main() {
  9.     int x;
  10.     scanf("%d", &x);
  11.    
  12.     while (x != 0) {
  13.         int kwiaty = 0, liscie = 0, i ;
  14.         for ( i = 0; i < 15; i++) {
  15.             if (x % 2 == 0) {
  16.                 x /= 2;
  17.                 kwiaty++;
  18.             }
  19.             else if (x == 1) {
  20.                 break;
  21.             }
  22.             else {
  23.                 x = 3 * x + 1;
  24.                 liscie++;
  25.             }
  26.             i++;
  27.         }
  28.         if (x == 1) {
  29.             printf("TAK %d %d\n", kwiaty, liscie);
  30.         }
  31.         else if (x != 1) {
  32.             printf("NIE\n");
  33.         }
  34.        
  35.         scanf("%d", &x);
  36.     }
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement