Promi_38

cf 313A

Jan 17th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     char s[25];
  7.     scanf("%s", s);
  8.     int i, n = strlen(s);
  9.    
  10.     if(s[0] == '-')
  11.     {
  12.         if(n == 3 && s[2] == '0')
  13.         {
  14.             printf("0\n");
  15.         }
  16.         else
  17.         {
  18.             for(i = 0; i <= n - 3; i++) printf("%c", s[i]);
  19.             if(s[n - 1] > s[n - 2]) printf("%c\n", s[n - 2]);
  20.             else printf("%c\n", s[n - 1]);
  21.         }
  22.     }
  23.     else for(i = 0; i < n; i++) printf("%c", s[i]);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment