Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5. int i, j, broj, red, stupac;
  6. char slovo;
  7.  
  8. scanf(" %c%d", &slovo, &broj);
  9. if(broj < 1 || broj > 8){
  10. printf("Krivi unos!");
  11. return 0;
  12. }
  13.  
  14. red = broj - 1;
  15.  
  16. for(i = 97; i < 105; i++){
  17. if((int)slovo == i){
  18. stupac = i - 97;
  19. }
  20. }
  21.  
  22. if(red % 2 == 0){
  23. if(stupac % 2 == 0){
  24. printf("crno\n");
  25. }else{
  26. printf("bijelo\n");
  27. }
  28. } else{
  29. if(stupac % 2 == 0){
  30. printf("bijelo\n");
  31. }else{
  32. printf("crno\n");
  33. }
  34. }
  35.  
  36. for(i = 0; i < 8; i++){
  37. for(j = 0; j < 8; j++){
  38. if(j == stupac-1 && i == red-2) printf("%c%d ", j+97, i+1);
  39. if(j == stupac+1 && i == red-2) printf("%c%d ", j+97, i+1);
  40. if(j == stupac+2 && i == red-1) printf("%c%d ", j+97, i+1);
  41. if(j == stupac+2 && i == red+1) printf("%c%d ", j+97, i+1);
  42. if(j == stupac+1 && i == red+2) printf("%c%d ", j+97, i+1);
  43. if(j == stupac-1 && i == red+2) printf("%c%d ", j+97, i+1);
  44. if(j == stupac-2 && i == red+1) printf("%c%d ", j+97, i+1);
  45. if(j == stupac-2 && i == red-1) printf("%c%d ", j+97, i+1);
  46. }
  47. }
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement