Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # include <iostream>
  2. # include <cmath>
  3. using namespace std;
  4.  
  5. struct Wektor2d
  6. {
  7. double x,y;
  8. }
  9. double dlugosc(Wektor2d w)
  10. {
  11. double norma;
  12. norma=sqrt(pow(w.x,2)+pow(w.y,2));
  13. return norma;
  14. }
  15. void inssert (Wektor2d*x,int n)
  16. {
  17. for (int i=1;i<n;i++)
  18. {
  19. int j=i;
  20. while(j>0 && dlugosc(x[j-1])>dlugosc(x[j]))
  21. {
  22. Wektor2d t=x[j];
  23. x[j]=x[j-1];
  24. x[j-1]=t;
  25. j--;
  26. }
  27. }
  28.  
  29.  
  30. }
  31.  
  32.  
  33.  
  34. int main()
  35. {
  36. Wektor2d w;
  37. cin>>w.x>>w.y;
  38. double norma=dlugosc(w);
  39. int n;
  40. cin>>n;
  41. Wektor2d*x=new Wektor2d[n];
  42. for(int i=0;i<n;i++)
  43. cin>>x.x[i]>>x.y[i];
  44. inssert (x,n);
  45.  
  46.  
  47. system ("pause");
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement