Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- # include <cmath>
- using namespace std;
- struct Wektor2d
- {
- double x,y;
- }
- double dlugosc(Wektor2d w)
- {
- double norma;
- norma=sqrt(pow(w.x,2)+pow(w.y,2));
- return norma;
- }
- void inssert (Wektor2d*x,int n)
- {
- for (int i=1;i<n;i++)
- {
- int j=i;
- while(j>0 && dlugosc(x[j-1])>dlugosc(x[j]))
- {
- Wektor2d t=x[j];
- x[j]=x[j-1];
- x[j-1]=t;
- j--;
- }
- }
- }
- int main()
- {
- Wektor2d w;
- cin>>w.x>>w.y;
- double norma=dlugosc(w);
- int n;
- cin>>n;
- Wektor2d*x=new Wektor2d[n];
- for(int i=0;i<n;i++)
- cin>>x.x[i]>>x.y[i];
- inssert (x,n);
- system ("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement