Vprento

10.Cik-cak1

Nov 9th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 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 > lastDigit) {
  15.     checkGreater = 1;
  16.     } else if(digit < lastDigit) {
  17.     checkGreater = 0;
  18.     } else {
  19.     flag = 0;
  20.     }
  21.     temp /= 10;
  22.     while (temp>0) {
  23.     digit = temp % 10;
  24.     //  printf("LAST DIGIT: %d\n", lastDigit);
  25.     //  printf("CURR DIGIT: %d\n", digit);
  26.     //  printf("CHECK FOR GREATER: %d\n", checkGreater);
  27.     if (checkGreater) {
  28.     if (lastDigit > digit) {
  29.     flag = 0;
  30.     }
  31.     checkGreater = 0;
  32.     } else {
  33.     if (lastDigit < digit) {
  34.     flag = 0;
  35.     }
  36.     checkGreater = 1;
  37.     }
  38.     if (lastDigit == digit) {
  39.     flag = 0;
  40.     }
  41.     lastDigit = digit;
  42.     temp /= 10;
  43.     }
  44.     if (flag) {
  45.     printf("%d\n", a);
  46.     }
  47.     }
  48.     return 0;
  49. }
Add Comment
Please, Sign In to add comment