Advertisement
Guest User

Untitled

a guest
Dec 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. bool znak(char* slowo){
  8.     if((strlen(slowo) > 1 && (slowo[0] >= 'a' && slowo[0] <= 'z')) || (slowo[0] >= 'A' && slowo[0] <= 'Z') || (slowo >= 33 && slowo <= 47)) {
  9.         return true;
  10.     }
  11.     return false;
  12. }
  13.  
  14. int main(){
  15.     int n;
  16.     char slowo1[11],slowo2[11];
  17.     scanf("%d",&n);
  18.     for(int i=0;i<n;i++){
  19.         scanf("%s",&slowo1);
  20.         scanf("%s",&slowo2);
  21.    
  22.         int x=atoi(slowo1);
  23.         int y=atoi(slowo2);
  24.         if (!znak(slowo1) && !znak(slowo2)){
  25.             int suma=0;
  26.             suma=x+y;
  27.             printf("%d ",suma);
  28.        
  29.         }
  30.        
  31.         else if (znak(slowo1) && znak(slowo2)){
  32.             printf("%c ",strcat(slowo1,slowo2));
  33.            
  34.         }
  35.        
  36.         else if (znak(slowo1) && !znak(slowo2)){
  37.             printf("%c ",slowo1[y-1]);
  38.        
  39.         }
  40.         else
  41.             printf("%c \n",slowo2[x-1]);
  42.            
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement