C 12
Random.c Guest on 5th April 2021 10:44:25 AM
  1. #include <stdio.h>
  2.  
  3. main(int argc, char *argv[])
  4. {
  5.    int i,m,n;
  6.    long j;
  7.    int temp;
  8.  
  9.    if(argc != 3)
  10.    {
  11.       printf("usage random n,m where n is the number of random sorted\n");
  12.       printf("numbers and m is the number of digits\n");
  13.       exit(0);
  14.    }
  15.  
  16.   printf("argv[0] = %s\n",argv[0]);
  17.   printf("argv[1] = %s\n",argv[1]);
  18.  
  19.    m = atoi (argv[1]);
  20.    n = atoi (argv[2]);
  21.  
  22.    j = 1;
  23.    for (i=0; i<n; i++)
  24.       j *= 10;
  25.    srand(time(NULL)%37);
  26.    for (i=0; i<m; i++)
  27.    {
  28.       printf("%5d ",rand() % j);
  29.         if (((i+1)%10) == 0)
  30.            printf("\n");
  31.    }
  32.  
  33.    printf("\n");
  34. }

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.