Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void overCiarovyKod(char *pole)
  4. {  
  5.     int celksuma = 0;
  6.     int k, j, i;
  7.    
  8.    
  9.     for(i = 1; i < 13; i++)
  10.     {
  11.         j = i % 2;
  12.  
  13.         if(j = 0)
  14.  
  15.             celksuma = celksuma + pole[i] - 48;
  16.         else
  17.  
  18.             if((pole[i]) * 2 <= 10)
  19.                 celksuma = celksuma + (pole[i]) * 2;
  20.             else
  21.                 celksuma = celksuma + ((pole[i]) * 2) - 9;
  22.     }
  23.  
  24.     k = celksuma % 10;
  25.    
  26.     if(k != pole[14])
  27.     {
  28.         printf("FAIL\n");
  29.     }
  30.     else
  31.     {
  32.         printf("OK\n");
  33.     }
  34.  
  35. }
  36.  
  37.  
  38. int main()
  39. {
  40.     char pole[] = "12391000105862";
  41.     overCiarovyKod(pole);
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement