Advertisement
hamaXD

CPT lab01-03

Aug 27th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int check_char(char c){
  5.     if(c>='A'&&c<'Z'){
  6.         return 0;
  7.     }
  8.     else if(c>='a'&&c<='z'){
  9.         return 1;
  10.     }else{
  11.         return -1;
  12.     }  
  13. }
  14. char enc_char(char c){
  15.     int x = check_char(c);
  16.     int ascii ;
  17.     if(x==1){
  18.         c=c+2;
  19.         return c;
  20.     }else if(x==0){
  21.         c=c+1;
  22.         return c;
  23.     }else{
  24.         return c;
  25.     }
  26.    
  27. }
  28. int main(){
  29.    
  30.     int i = 0; char input[50],ch;
  31.     char c;
  32.     while((scanf("%s",&input) != EOF)) {
  33.         int n = strlen(input);
  34.         for(i=0;i<n;i++){
  35.             ch = enc_char(input[i]);
  36.             input[i]=ch;
  37.         }
  38.         printf("%s\n",input);
  39.        
  40.     }
  41.     printf("EOF\n");
  42.     return 0 ;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement