Advertisement
Soupborsh

chubrik_and_numero

Jun 20th, 2025 (edited)
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | Source Code | 0 0
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6.  
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11.  
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #include <ctype.h>
  17. #include <stdio.h>
  18.  
  19. #define ULL unsigned long long
  20. #define LL long long
  21. #define uint unsigned int
  22. #define uchar unsigned char
  23.  
  24. #define INV(x) ('9' - (x) + '0')
  25.  
  26. int main(void) {
  27.   int ch;
  28.  
  29.   while (isspace(ch = getchar()))
  30.     ; // whitespace skip
  31.  
  32.   do {
  33.     if (INV(ch) < ch) {
  34.       ch = INV(ch);
  35.     }
  36.     if (ch != '0') {
  37.       break;
  38.     }
  39.   } while (!isspace(ch = getchar()) && (ch != EOF));
  40.  
  41.   if (isspace(ch) || (ch == EOF)) {
  42.     putchar('9');
  43.     putchar('\n');
  44.     return 0;
  45.   }
  46.  
  47.   do {
  48.     if (INV(ch) < ch) {
  49.       ch = INV(ch);
  50.     }
  51.     putchar(ch);
  52.   } while (!isspace(ch = getchar()) && (ch != EOF));
  53.  
  54.   putchar('\n');
  55.  
  56.   return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement