Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- struct punkt {
- double x;
- double y;
- double z;
- long long odl;
- };
- bool q(punkt a,punkt b)
- {
- return a.odl<b.odl;
- }
- punkt tab[1002];
- int main()
- {
- int n;
- cin>>n;
- for(int i=0;i<n;i++)
- {
- cin>>tab[i].x>>tab[i].y>>tab[i].z;
- tab[i].odl=tab[i].x*tab[i].x+tab[i].y*tab[i].y+tab[i].z*tab[i].z;
- }
- sort(tab, tab+n,q);
- for(int i=0;i<n;i++)
- {
- cout<<tab[i].x<<" "<<tab[i].y<<" "<<tab[i].z<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement