Advertisement
Guest User

gay antonio

a guest
Feb 14th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. main()
  3. {
  4.     int N, app, v[10], k, i;
  5.     i = 0;
  6.     printf("\nDammi N: ");
  7.     scanf("%d", &N);
  8.     while (i<N)
  9.     {
  10.         printf("\nDammi un valore: ");
  11.         scanf("%d", &v[i]);
  12.         i++;
  13.     }
  14.    
  15.     k=1;
  16.     while (k<N)
  17.     {
  18.         i=0;
  19.         while (i<N-k)
  20.         {
  21.             if (v[i]>v[i+1])
  22.                 {
  23.                     app= v[i];
  24.                     v[i]=v[i+1];
  25.                     v[i+1]=app;
  26.                 }
  27.                 i++;
  28.         }
  29.         k++;
  30.     }
  31.     i=0;
  32.     while (i<N)
  33.     {
  34.         printf("\nEcco il vettore ordinato: %d", v[i]);
  35.         i++;
  36.     }
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement