fork(4) download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <locale.h>
  5.  
  6.  
  7. char pole[64];
  8. void prn(){
  9. printf("\n");
  10. for (int y=0;y<8;y++){
  11. for (int x=0;x<8;x++)
  12. printf("%S",pole[y*8+x]?L" X":L" -");
  13. printf("\n");
  14. }
  15. printf("\n");
  16. }
  17. void res(){
  18. for (int o=0;o<8;o++)
  19. ((long long *)pole)[o]=0;
  20. }
  21.  
  22. bool e_1(int x,int y){
  23. return (x>=0 and x<=7 and y>=0 and y<=7);
  24. }
  25.  
  26. void m_1(int x,int y){
  27. for (int i=-10;i<10;i++){
  28. if (e_1(x+i,y+i))pole[(y+i)*8+(x+i)]=1;
  29. if (e_1(x-i,y+i))pole[(y+i)*8+(x-i)]=1;
  30. }
  31. }
  32.  
  33. void m_2(int x,int y){
  34. for (int _x=0;_x<8;_x++)
  35. for (int _y=0;_y<8;_y++)
  36. pole[_y*8+_x]=abs(_x-x)==abs(_y-y);
  37. }
  38.  
  39. void m_3(int x,int y){
  40. for (int _x=0;_x<8;_x++){
  41. if (int u=y+(x-_x);u>=0 and u<=7) pole[u*8+_x]=1;
  42. if (int u=y+(_x-x);u>=0 and u<=7) pole[u*8+_x]=1;
  43. }
  44. }
  45.  
  46. int main()
  47. {
  48. res();
  49. m_1(3,4);
  50. prn();
  51.  
  52. res();
  53. m_2(5,6);
  54. prn();
  55.  
  56. res();
  57. m_3(2,1);
  58. prn();
  59.  
  60.  
  61. return 0;
  62. }
  63.  
Success #stdin #stdout 0s 4548KB
stdin
Standard input is empty
stdout
 - - - - - - - X
 X - - - - - X -
 - X - - - X - -
 - - X - X - - -
 - - - X - - - -
 - - X - X - - -
 - X - - - X - -
 X - - - - - X -


 - - - - - - - -
 X - - - - - - -
 - X - - - - - -
 - - X - - - - -
 - - - X - - - X
 - - - - X - X -
 - - - - - X - -
 - - - - X - X -


 - X - X - - - -
 - - X - - - - -
 - X - X - - - -
 X - - - X - - -
 - - - - - X - -
 - - - - - - X -
 - - - - - - - X
 - - - - - - - -