Advertisement
Silviyaa

Двумерна графика

Mar 30th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <graphics.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. float x[] = {-26.8, 12.2, 71.9, -34.6, 18.5, -19.4, 57.5, 43.2, 13.7};
  8. float y[] = {32.7, -52.7, 23.6, 15.1, 68.4, 43.6, -22.5, 33.7, 30.8};
  9. int n=sizeof(x)/sizeof(x[0]);
  10. int x0=100;
  11. int y0=400;
  12. float Px=500, Py=500;
  13. float xmin=x[0], xmax=x[0],ymin=y[0],ymax=y[0];
  14.  
  15. for(int i=0;i<n;i++){
  16.  
  17. if(x[i]<xmin){
  18.     xmin=x[i];
  19. }
  20. if(x[i]<xmax){
  21.     xmax=x[i];
  22. }
  23. if(y[i]<ymin){
  24.     ymin=y[i];
  25. }
  26. if(y[i]<ymax){
  27.     ymax=y[i];
  28. }
  29. }
  30. float sx = (xmax-xmin)/Px;
  31. float sy = (ymax-ymin)/Py;
  32.  
  33. initwindow(800,800);
  34. setfillstyle(1, RED);
  35. int xpr,ypr;
  36.  
  37. for(int i=0; i<n; i++){
  38.  
  39. xpr=x0 +(x[i]-xmin)/sx;
  40. ypr=y0 +(y[i]-ymin)/sy;
  41. circle(xpr,ypr,6);
  42. }
  43. //getch();
  44. return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement