Advertisement
Vprento

5.Heksadecimalni cifri

Nov 9th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.     char c;
  4.     int sum = 0;
  5.     while (scanf("%c", &c) != '.')
  6. {
  7.     if (c == '.') {
  8.     break;
  9.     }
  10.     int digit = 0;
  11.     if (c >= 'A' && c <= 'F') {
  12.     digit = c - 'A' + 10;
  13.     } else if(c>= 'a' && c<='f') {
  14.     digit = c - 'a' + 10;
  15.     } else if (c>='0' && c <='9') {
  16.     digit = c - '0';
  17.     }
  18.     sum+= digit;
  19.     }
  20.     if (sum % 16 == 0) {
  21.     if ((sum %10 == 6) && ((sum/10)%10 == 1)) {
  22.     printf("Poln pogodok");
  23.     } else {
  24.     printf("Pogodok");
  25.     }
  26.     } else {
  27.     printf("%d\n", sum);
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement