Advertisement
patryk

Untitled

Apr 3rd, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<fstream>
  5. #include<time.h>
  6. #include<cstdlib>
  7. #include<algorithm>
  8.  
  9. #define N 20000
  10.  
  11. using namespace std;
  12. static unsigned long int next = 1;
  13.  
  14. int rand(void)
  15. {
  16.     next = next * 1103515245 + 12345;
  17.     return (unsigned int)(next/65536) % N;
  18. }
  19.  
  20. void srand(unsigned int seed)
  21. {
  22.     next = seed;
  23. }
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29.     int tab[N], dane[N], i, k;
  30.     for(i=0; i<N; i++) tab[i] = 0;
  31.  
  32.     srand(time(NULL));
  33.     for(i=0; i<N; i++){
  34.         do{
  35.             k = rand();
  36.         }while(tab[k] != 0);
  37.         tab[k]++;
  38.         dane[i] = k;
  39.     }
  40.  
  41.     fstream plik;
  42.  
  43.     for(int j=1; j<16; j++){
  44.     plik.open("300000.txt", ios::out | ios::app);
  45.         if(plik.good() == true){
  46.         for(i=0; i<N; i++) plik << "Janusz\t" <<  "Weiss\t" << dane[i] + j*100000 << endl;
  47.         plik.close();
  48.     }
  49.     }
  50.  
  51.     //for(i=0; i<N; i++) printf("%d\n", dane[i]);
  52.  
  53.     sort(dane, dane+N);
  54.  
  55.     //for(i=0; i<N; i++) printf("%d\t", dane[i]);
  56.  
  57.     printf("Koniec");
  58.     getch();
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement