Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits\stdc++.h"
- using namespace std;
- int main()
- {
- vector<float> vec;
- FILE *fp;
- int i;
- float x,y;
- if ((fp=fopen("D:\\Games\\1.txt","w"))==NULL)
- {
- printf("error");
- }
- else
- {
- for (int i = 0; i < 100; i++)
- {
- x=rand()/32767.0;
- y=(-0.5f)*log(x);
- vec.push_back(y);
- }
- sort(vec.begin(),vec.end());
- double sekay = 0.5;
- int ind = 0;
- while(sekay < 4)
- {
- int am = 0;
- while(ind < vec.size() && vec[ind] < sekay)
- {
- am++;
- ind++;
- }
- fprintf(fp, "From %f to %f - %d \n",sekay-0.5,sekay,am);
- sekay+=0.5;
- }
- fclose(fp);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement