Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<stdlib.h>
- struct cerc
- {
- int x; int y; int r;
- } v[2000];
- void isort( cerc v[], int left, int right )
- {
- int i, j;
- i = left; j = right;
- int current;
- int last=0;
- cerc temp;
- if( left >= right )
- return;
- for( current = left+1; current <= right; ++current )
- {
- if( (float)v[current].x/v[current].y < (float)v[left].x/v[left].y )
- {
- ++last;
- if(i <= j)
- {
- /*temp.x = v[i].x;
- temp.y = v[i].y;
- temp.r = v[i].r;
- v[i].x = v[j].x;
- v[i].y = v[j].y;
- v[i].r = v[j].r;
- v[j].x = temp.x;
- v[j].y = temp.y;
- v[j].r = temp.r;*/
- temp=v[i];
- v[i]=v[j];
- v[j]=temp;
- i++; j--;
- }
- }
- }
- isort( v, left, last-1 );
- isort( v, last+1, right );
- }
- int main ()
- {
- freopen("cerc3.in", "rt", stdin);
- freopen("cerc3.out", "wt", stdout);
- int i,n,l=0;
- double qq=0;
- scanf("%i", &n);
- for(i=0;i<n;i++)
- scanf("%i %i %i", &v[i].x, &v[i].y, &v[i].r);
- isort(v,0,n-1);
- for(i=0;i<n;i++)
- if(qq!=(double)v[i].x/v[i].y*1e-4)
- qq=(double)v[i].x/v[i].y*1e-4,l++;
- for(i=0;i<n;i++)
- printf("%i %i %i\n", v[i].x, v[i].y, v[i].r);
- printf("%d", l);
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment