Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 100
- int ox[100], oy[100];
- int borx[100],bory[100];
- int n;
- void citire(int *x, int n){
- int i;
- for(i=0; i<n; i++){
- printf("coordonata %d:",i);scanf("%d",&x[i]);
- }
- }
- void afisare(int *x,int *y,int n)
- {
- int i;
- for(i=0; i<n; i++){
- printf("(%d,%d)",x[i],y[i]);
- }
- printf("\n");
- }
- void parcus(int *x,int *y,int *borx,int *bory, int poz)
- {
- int k,z;
- int i=1;
- int minx=100000;
- int miny=100000;
- while(i<=n){
- if(ox[i]<minx){
- minx=ox[i];
- z=i;
- for(int j=1;j<=n;++j){
- if(oy[j]<miny){
- miny=oy[j];
- k=j;
- }
- }
- }
- else i++;
- }
- borx[poz]=minx;
- bory[poz]=miny;
- for (i = z; i <= n - 1; i++)
- borx[i] = borx[i+1];
- n = n - 1;
- for (i = k; i <= n - 1; i++)
- bory[i] = bory[i+1];
- n = n - 1;
- parcurs(x,y,borx,bory,poz++);
- }
- int main()
- {
- printf("n=");scanf("%d",&n);
- if(n>100){
- printf("prea multe coordonate!\n");return 0;
- }
- printf("coordonata x\n");
- citire(x,n);
- printf("coordonata y\n");
- citire(y,n);
- printf("Coordonatele sunt\n");
- afisare(x,y,n);
- parcus(ox,oy,0,0,1);
- afisare(xbor,ybor,n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement