Advertisement
aimon1337

Untitled

May 12th, 2020
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAX 100
  4.  
  5. int ox[100], oy[100];
  6. int borx[100],bory[100];
  7. int n;
  8.  
  9. void citire(int *x, int n){
  10.     int i;
  11.     for(i=0; i<n; i++){
  12.         printf("coordonata %d:",i);scanf("%d",&x[i]);
  13.     }
  14. }
  15.  
  16. void afisare(int *x,int *y,int n)
  17. {
  18.     int i;
  19.     for(i=0; i<n; i++){
  20.         printf("(%d,%d)",x[i],y[i]);
  21.     }
  22.     printf("\n");
  23. }
  24.  
  25. void parcus(int *x,int *y,int *borx,int *bory, int poz)
  26. {
  27.     int k,z;
  28.     int i=1;
  29.    int minx=100000;
  30.    int miny=100000;
  31.     while(i<=n){
  32.      if(ox[i]<minx){
  33.         minx=ox[i];
  34.         z=i;
  35.         for(int j=1;j<=n;++j){
  36.             if(oy[j]<miny){
  37.                 miny=oy[j];
  38.                     k=j;
  39. }
  40.             }
  41.         }
  42.         else i++;
  43.     }
  44.     borx[poz]=minx;
  45.     bory[poz]=miny;
  46. for (i = z; i <= n - 1; i++)
  47.         borx[i] = borx[i+1];
  48. n = n - 1;
  49. for (i = k; i <= n - 1; i++)
  50.         bory[i] = bory[i+1];
  51. n = n - 1;
  52.     parcurs(x,y,borx,bory,poz++);
  53. }
  54.  
  55. int main()
  56. {
  57.     printf("n=");scanf("%d",&n);
  58.     if(n>100){
  59.         printf("prea multe coordonate!\n");return 0;
  60.     }
  61.     printf("coordonata x\n");
  62.     citire(x,n);
  63.     printf("coordonata y\n");
  64.     citire(y,n);
  65.     printf("Coordonatele sunt\n");
  66.     afisare(x,y,n);
  67.     parcus(ox,oy,0,0,1);
  68.     afisare(xbor,ybor,n);
  69.     return 0;
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement