Advertisement
Mayur_Pipaliya

C

Nov 13th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int _random()
  5. {
  6.         char path[1035];
  7.         FILE *fp = popen("bash -c 'echo $RANDOM'", "r");
  8.         while (fgets(path, sizeof(path)-1, fp) != NULL) { // printf("%s", path);
  9.         }
  10.         pclose(fp);
  11.          
  12.         srand(atoi(path)); // printf("%d", toi(path));
  13.         return ((rand()%220)-100);
  14. }
  15.  
  16. main()
  17. {
  18.         int record;
  19.         int up=0,mid=0,low=0;
  20.  
  21.         while(1)
  22.         {
  23.                 record=_random();
  24.                 // printf("%d \n",record);
  25.                 if(record>=90)
  26.                 {
  27.                         if(up != 1)
  28.                                 printf("__Up %d \n",record);
  29.                         up=1;
  30.                 }
  31.                 else if(record<90 && record >=-90)
  32.                 {
  33.                         if(mid != 1)
  34.                                 printf("__Mid %d \n",record);    
  35.                         mid=1;
  36.                 }
  37.                 else
  38.                 {
  39.                         if(low != 1)
  40.                                 printf("__Low %d \n",record);    
  41.                         low=1;
  42.                 }
  43.                 if(low == 1 && mid == 1 && up ==1)break;
  44.         }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement