Advertisement
dllbridge

Untitled

Nov 9th, 2023
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4.  
  5. char sz[19];
  6.  
  7. int nCell[3];
  8.  
  9. /////////////////////////////////////////////
  10. int main()                                 //
  11. {
  12.    
  13.    
  14.     scanf("%s", sz);
  15.  
  16.     printf("1st cell is : ");    
  17.  
  18.  
  19.     int i = 0;
  20.  
  21.     while(sz[i] != 0)
  22.     {
  23.        
  24.        
  25.        
  26.        if(sz[i]   % 2)
  27.        if(sz[i+1] % 2)      { printf("black\n"); i+=2; break; }
  28.        if(sz[i]   % 2 == 0)
  29.        if(sz[i+1] % 2 == 0) { printf("black\n"); i+=2; break; }
  30.        
  31.  
  32.        printf("whaite\n");
  33.        
  34.        nCell[1] = 1;
  35.        
  36.        i+=2;   
  37.        
  38.        break;  
  39.        
  40.     }
  41.  
  42.     printf("2nd cell is : ");
  43.    
  44.     while(sz[i] != 0)
  45.     {
  46.        
  47.        if(sz[i]   % 2)
  48.        if(sz[i+1] % 2)      { printf("black\n"); i+=2; break; }
  49.        if(sz[i]   % 2 == 0)
  50.        if(sz[i+1] % 2 == 0) { printf("black\n"); i+=2; break; }
  51.        
  52.  
  53.        printf("whaite\n");
  54.        
  55.        nCell[2] = 1;
  56.        
  57.        break;      
  58.        
  59.     }
  60.  
  61.  
  62.     if(nCell[1] == nCell[2]) printf("Yes, same colors."         );
  63.     else                     printf("Different colors of cells.");
  64.    
  65. return 0;
  66. }
  67.  
  68.  
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement