Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. #define MAX_N 10
  4.  
  5. int tomb[MAX_N+1];
  6. int i,j,n,munka;
  7. main()
  8. {
  9.       printf("n=");
  10.       scanf("%d",&n);
  11.       for (i=1;i<=n;i++)
  12.       {
  13.           printf("tomb[%d]:",i);
  14.           scanf("%d",&tomb[i]);
  15.           }
  16.           for(i=1;i<=n-1;i++)
  17.           for(j=1;j<=n-i;j++)
  18.           if(tomb[j]>tomb[j+1])
  19.           {
  20.             munka=tomb[j];
  21.             tomb[j]=tomb[j+1];
  22.             tomb[j+1]=munka;
  23.             }
  24.             puts("A rendezett tomb: ");
  25.             for(i=1;i<=n;i++)
  26.             printf("tomb[%d]=%d\n",i,tomb[i]);
  27.             system("pause");
  28.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement