Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7.  
  8. int main( )
  9. {
  10. /* request autodetection */
  11. int gdriver = DETECT, gmode, errorcode;
  12. int midx, midy;
  13.  
  14. /* initialize graphics and local variables */
  15. initgraph(&gdriver, &gmode, "");
  16.  
  17. /* read result of initialization */
  18. errorcode = graphresult();
  19. if (errorcode != grOk) { /* an error occurred */
  20. printf("Graphics error: %s\n", grapherrormsg(errorcode));
  21.  
  22. printf("Press any key to halt:");
  23. getch();
  24. exit(1); /* terminate with an error code */
  25. }
  26.  
  27. initwindow( 800 , 800 , "Norbi face sah" );
  28. settextstyle(0, 0, 1);
  29. //setusercharsize(3,2,3,2);
  30. int posX=0;
  31. int linie=1;
  32. int posY=0;
  33. int coloana=1;
  34. int x,y;
  35. char xClick[3];
  36. char yClick[3];
  37. char posxCh[3];
  38. char posyCh[3];
  39. char pozitia[2];
  40. for(int i=0; i<64; i++){
  41.  
  42.  
  43.  
  44. //determin posX in fct de i
  45. linie=i%8;
  46. posX=linie*50; //determin inceputul pe x
  47. //determin posY in fct de i
  48. coloana=i/8;
  49. posY=coloana*50; //determin inceputul pe y
  50.  
  51. sprintf(posxCh,"%d",posX);
  52. sprintf(posyCh,"%d",posY);
  53. sprintf(pozitia,"%d",i);
  54.  
  55.  
  56.  
  57. //in functie de pozitie colorez
  58. if(linie%2==0 && coloana%2==0){
  59. setfillstyle(SOLID_FILL, WHITE);
  60.  
  61.  
  62. }else if(linie%2==1 && coloana%2==1){
  63. setfillstyle(SOLID_FILL, WHITE);
  64.  
  65.  
  66. }else{
  67. setfillstyle(SOLID_FILL, BLACK);
  68.  
  69.  
  70. }
  71. //desenez tabla
  72. bar(posX,posY,posX+50,posY+50);
  73. //transform int in char
  74. sprintf(posxCh,"%d",posX);
  75. sprintf(posyCh,"%d",posY);
  76. sprintf(pozitia,"%d",i);
  77.  
  78. //afisez pozitia si pixeli
  79. moveto(posX,posY);
  80. outtext(posyCh);
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88. }
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. while( !kbhit() ){
  97. if(ismouseclick(WM_LBUTTONDOWN)){
  98. getmouseclick(WM_LBUTTONDOWN, x, y);
  99. sprintf(xClick,"%d",x);
  100. sprintf(yClick,"%d",y);
  101. }
  102. }
  103.  
  104.  
  105.  
  106. closegraph( );
  107.  
  108. return( 0 );
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement