Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <graphics.h>
  2. #include <iostream>
  3. #include <limits.h>
  4.  
  5. using namespace std;
  6.  
  7. void MinMax(int n, double arr[], double &min, double &max){
  8. for(int i = 0; i < n; i++)
  9. if(arr[i] > max) max = arr[i];
  10. else if(arr[i] < min) min = arr[i];
  11. }
  12.  
  13. void Points(int n, double vhx[], double vhy[], double x0, double y0, double xmin, double ymin,
  14. double Sx, double Sy){
  15. for(int i = 0; i < n; i++){
  16. int xp = x0 + (vhx[i] - xmin)/Sx;
  17. int yp = y0 - (vhy[i] - ymin)/Sy;
  18. circle(xp, yp, 5);
  19. }
  20.  
  21. for(int i = 1; i < n; i++){
  22. //line(x0 + vhx[i-1], y0 - vhy[i-1], x0 + vhx[i], y0 - vhy[i]);
  23. }
  24. }
  25.  
  26. void ax(int d, double x0, double y0, int P, int D, double min, double S){
  27. if(d == 0){
  28. int Ip = P/D;
  29. cout<<Ip<<endl;
  30. }else{
  31. int Jp = P/D;
  32. cout<<Jp<<endl;
  33. }
  34. }
  35.  
  36. int main(){
  37. double x0 = 50, y0 = 600, px = 600, py = 550, dx = 40, dy = 40;
  38. double VhodX[8] = {10.2, 115.1, 222.8, 118.5, 333.1, 217.4, 262.9, 413.8};
  39. double VhodY[8] = {120.1, 321.3, 412.5, 118.3, 212.2, 134.4, 222.7, 133.2};
  40. double minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN;
  41. int n = 8;
  42.  
  43. initwindow(800, 800, "p1");
  44.  
  45. MinMax(n, VhodX, minX, maxX);
  46. MinMax(n, VhodY, minY, maxY);
  47.  
  48. double Sx = (maxX - minX) / px;
  49. double Sy = (maxY - minY) / py;
  50.  
  51. Points(n, VhodX, VhodY, x0, y0, minX, minY, Sx, Sy);
  52. ax(0, x0, y0, 0, 0, minX, Sx);
  53. getch();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement