seergiomv

Ejercicio 19.4

Dec 31st, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 500
  4. void array();
  5. int main(){
  6.     int a[N], b[N], c[N];
  7.     array(a,b,c);
  8. }
  9. void array(int a[N], int b[N], int c[N]){
  10.     int x[3*N], cero = 0, count = 0;
  11.     for (int i = 0; i < N; i++){
  12.         a[i] = rand() % 2001;
  13.         b[i] = rand() % 2001;
  14.         c[i] = rand() % 2001;
  15.     }
  16.     for (int i = 0; i < N; i++){
  17.         x[i] = a[i];
  18.         x[i+N] = b[i];
  19.         x[i + 2*N] = c[i];
  20.     }
  21.  
  22.     for (int i = 1; i < 3*N; i++){
  23.         for (int j = 0; j < 3*N -1; j++){
  24.             if (x[j] > x[j+1]){
  25.                 cero = x[j];
  26.                 x[j] = x[j+1];
  27.                 x[j+1] = cero;
  28.             }
  29.         }
  30.     }
  31.     for (int i = 0; i < 3*N; i++){
  32.         printf("%d\n",x[i]);
  33.         count = 1 + i;
  34.     }
  35.     printf("En total hay %d numeros",count);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment