Vprento

11.Cik-cak2

Nov 9th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.     int a;
  4.     int mainFlag = 0;
  5.     while (scanf("%d", &a)) {
  6.     if (a<10) {
  7.     continue;
  8.     }
  9.     int flag = 1;
  10.     int temp = a;
  11.     int digit = (temp / 10) % 10;
  12.     int lastDigit = temp % 10;
  13.     int checkGreater;
  14.     if (digit >= 5) {
  15.     checkGreater = 1;
  16.     } else if(digit < 5) {
  17.     checkGreater = 0; }
  18.     temp /= 10;
  19.     while (temp>0) {
  20.     digit = temp % 10;
  21.     //  printf("LAST DIGIT: %d\n", lastDigit);
  22.     //  printf("CURR DIGIT: %d\n", digit);
  23.     //  printf("CHECK FOR GREATER: %d\n", checkGreater);
  24.     if (checkGreater) {
  25.     if (digit < 5) {
  26.     flag = 0; }
  27.     checkGreater = 0;
  28.     } else {
  29.     if (digit >= 5) {
  30.     flag = 0;  }
  31.     checkGreater = 1; }
  32.     temp /= 10;  }
  33.     if (flag) {
  34.     printf("%d\n", a);  }}
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment