Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #include <iostream>
  2. #include"graphics.h"
  3. using namespace std;
  4.  
  5. void minmax(int n, double A[], double&Amin, double&Amax)
  6. {
  7. Amin=A[0];
  8. Amax=A[0];
  9.  
  10. for (int i=1; i<n; i++)
  11. {
  12. if(Amin<A[i])
  13. Amin=A[i];
  14. if(Amax>A[i])
  15. Amax=A[i];
  16. }
  17. }
  18.  
  19. void points(int n,double Vhodx[], double VhodY[],double xmin,double ymin,int x0,int y0,double sx,double sy)
  20. {
  21. int xp,yp;
  22. // int x0,y0;
  23.  
  24. for(int i=0; i<n; i++)
  25. {
  26. xp=x0 + (Vhodx[i] - xmin)/sx;
  27. yp=y0 - (VhodY[i] - ymin)/sy;
  28. circle(xp,yp,5);
  29. //line (x0,y0,xp,yp);
  30. }
  31. }
  32.  
  33. void Axiis(int Dir, int x0,int y0, int D, double min, int P, double S)
  34. {
  35. double val;
  36. double I;
  37. char intStr[20];
  38. char* t;
  39. if(Dir!=0)
  40. {
  41. line (x0,y0,x0+P,y0);
  42. I=(P/D)-1;
  43. for (int i=0;i<I;i++)
  44. {
  45. line(x0+(i*D),y0,(x0+i*D),(y0+3));
  46. val=min+i*D;
  47. t=gcvt(val,10,intStr);
  48. settextjustify(1,2);
  49. outtextxy(x0+i*D,(y0+3),t);
  50. }
  51. }
  52. if (Dir==0)
  53. {
  54. line(x0,y0,x0,(y0-P));
  55. I=(P/D)-1;
  56. for(int i=0;i<I;i++)
  57. {
  58. line(x0,(y0-(i*D)),(x0-3),(y0-i*D));
  59. val=min+i*D;
  60. t=gcvt(val,10,intStr);
  61.  
  62. settextjustify(2,1);
  63. outtextxy(x0-3,(y0-i*D),t);
  64.  
  65. }
  66. }
  67. }
  68. int main()
  69. {
  70. initwindow(800,600,"");
  71.  
  72. double VhodX[8]={3.7, 4.5, 5.1, 6.9, 2.4, 3.1, 9.2, 7.2};
  73. double VhodY[8]={5.7, 1.5, 2.1, 3.9, 4.4, 5.1, 8.2, 7.9};
  74.  
  75. int px, py, y0, x0, dx, dy;
  76. x0=100;
  77. y0=500;
  78. px=500;
  79. py=300;
  80. dx=60;
  81. dy=60;
  82. double xmin, xmax, ymin, ymax, sx, sy;
  83. minmax(8,VhodX, xmin, xmax);
  84. minmax(8, VhodY, ymin, ymax);
  85. sx=(xmax-xmin)/px;
  86. sy=(ymax-ymin)/py;
  87. points(8,VhodX,VhodY,xmin,ymin,x0,y0,sx,sy);
  88. Axiis(1, x0,y0,50, xmin, px, sx);
  89. Axiis(0, x0,y0,50, ymin, px, sx);
  90.  
  91. getch();
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement