Guest User

Untitled

a guest
Oct 14th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2.  #include <ctype.h>
  3.  #include <malloc.h>
  4.  #define lim 102
  5.  
  6. int main()
  7.   {
  8.       int i,p;
  9.       scanf("%d\n",&p);
  10.       if (p>lim) return 0;
  11.       if (p<0) return 0;
  12.       if(p == 0) return 0;
  13.       if (isalpha(p)) return 0;
  14.  
  15.       char c;
  16.      
  17.       char* A =(char*)malloc(p*sizeof(char));
  18.        
  19.       i = 0;
  20.       while (i < p-1) {
  21.           c = getchar();
  22.           if (c == EOF)
  23.               break;
  24.           if (c == '\n')
  25.               break;
  26.           if(isdigit(c)){
  27.           c = c -'0';
  28.           c = 9 - c;
  29.           c = c + '0';
  30.           }
  31.           A[i++] = c;
  32.       }
  33.       A[i] = '\0';
  34.  
  35.       printf("%s", A);
  36.  
  37.       return 0;
  38.   }
Advertisement
Add Comment
Please, Sign In to add comment