SHARE
TWEET

Lab4.1

a guest Oct 12th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "fun.h"
  2. #include <stdio.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5. void fun(){
  6.     int mas[20],r;
  7.     srand(time(NULL));
  8.     for(int i = 0; i < 20; i++){
  9.         r = (rand() % 100) - 50;
  10.         mas[i] = r;
  11.         printf("%i | ",mas[i]);
  12.     }
  13.     int count = 0;
  14.     while(count < 20){
  15.         for(int i = 0; i < 19; i++){
  16.             int temp;
  17.             if(mas[i] < mas[i+1]){
  18.                 temp = mas[i];
  19.                 mas[i] = mas[i+1];
  20.                 mas[i+1] = temp;
  21.             }
  22.         }
  23.         count++;
  24.     }
  25.     printf("\n1): %i, 2): %i, 3): %i", mas[0], mas[1], mas[2]);
  26. }
RAW Paste Data
Top