SHARE
TWEET

4. zadatak seminarski

W1nt3rR Nov 21st, 2019 (edited) 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int proveraBoje(x, y){
  4.     if(x % 2 == y % 2)
  5.         return 1; //crna
  6.     else
  7.         return 0; //bela
  8. }
  9.  
  10. int main()
  11. {
  12.     int x1, y1, x2, y2, bojaP1, bojaP2;
  13.    
  14.     //Unos koordinata polja
  15.     printf("Unesite polja sahovske table u formatu: (x1,y1) (x2,y2)\n");
  16.     scanf("(%d,%d) (%d,%d)", &x1, &y1, &x2, &y2);
  17.    
  18.     //Provera Unosa
  19.     if((x1 > 8 || y1 > 8 || x2 > 8 || y2 > 8) || (x1 < 1 || y1 < 1 || x2 < 1 || y2 < 1)){
  20.         printf("To polje ne postoji.");
  21.         return 1;
  22.     }
  23.    
  24.     bojaP1 = proveraBoje(x1, y1);
  25.     bojaP2 = proveraBoje(x2, y2);
  26.    
  27.     //Komparacija i Ispis
  28.     if(bojaP1 == bojaP2){
  29.         printf("\nBoje polja su iste\n");
  30.     } else {
  31.         printf("\nBoje polja su razlicite\n");
  32.     }
  33.    
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top