ivana_andreevska

2

May 19th, 2021
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, i, c;
  6.     scanf("%d",&n);
  7.  
  8.     int brojacZaCifri=0;
  9.     int obratenBroj, max = 0;
  10.  
  11.  
  12.     if(n>9)
  13.     {
  14.         for (i =9; i <n; i++)
  15.         {
  16.             int temp = i;
  17.             obratenBroj = 0;
  18.             brojacZaCifri=0;
  19.             while (temp > 0)
  20.             {
  21.                 c = temp % 10;
  22.                 obratenBroj = 10*obratenBroj + c;
  23.                 brojacZaCifri++;
  24.                 temp /= 10;
  25.             }
  26.             if (obratenBroj % brojacZaCifri == 0)
  27.             {
  28.                 if (i > max) { max = i; }
  29.             }
  30.         }
  31.         printf("%d", max);
  32.     }
  33.     else
  34.     {
  35.         printf("Brojot ne e validen\n");
  36.     }
  37.  
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment