Guest User

code

a guest
Oct 12th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <fstream.h>
  2. #include <iomanip.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. int main()
  7. {
  8. float output;
  9. ifstream fin("4.dat");
  10. ofstream fout("4-1.dat");
  11. float c[10000], plot[100];
  12. int i,x;
  13.  
  14. for(i=0; i<10000; i++)
  15. {
  16. c[i]=rand()%1000;
  17. c[i]=c[i]/100-5;
  18. }
  19.  
  20. for(i=0;i<100;i++)
  21. plot[i]=0;
  22. for(i=0;i<10000;i++)
  23. {
  24. x=(c[i]+5)*10+1;
  25. plot[x]++;
  26. }
  27. for(i=0;i<100;i++)
  28. fout<<-5+0.1*i<<"\t"<<0.0001*plot[i]<<"\n";
  29. fout.close();
  30. return 0;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment