Advertisement
Skufler

Random

Jan 19th, 2017
102
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. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6.     int i, t, N, m, b, j;
  7.     scanf("%d", &N);
  8.     int a[N];
  9.     m = 3;
  10.     b = 10;
  11.     for(i = 0; i < N; i++)
  12.         a[i]= rand() % ( b - m) + m;
  13.    
  14.     for (i= N - 2; i >= 0; i--) {
  15.         for (j = 0;j <= i; j++) {
  16.             if  (a[j] > a[j+1])
  17.                 {
  18.                     t = a[j];
  19.                     a[j] = a[j+1];
  20.                     a[j+1] = t;
  21.                 }
  22.             }
  23.     }
  24.     for(i = 0; i < N; i++)
  25.         printf("%d ", a[i]);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement