Guest User

Untitled

a guest
Jun 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int n;
  5. int ranges;
  6. int perc;
  7. int rans;
  8. inline int myrand()
  9. {
  10.  return (rand()*rand())+rand();
  11. }
  12. main()
  13. {
  14.  srand(time(NULL));
  15.  freopen("1.in","w",stdout);
  16.  n=10;
  17.  ranges=10;
  18.  perc=5;
  19.  printf("%d\n",n);
  20.  for(int i=1;i<=n;i++)
  21.  {
  22.   for(int j=1;j<=n;j++)
  23.   {
  24.    rans=rand()%10000;
  25.    if(rans<=perc){printf("0");}
  26.    else{printf("%d",myrand()%ranges);}
  27.    if(j!=n){printf(" ");}
  28.   }
  29.   printf("\n");
  30.  }
  31.  return 0;
  32. }
Add Comment
Please, Sign In to add comment