Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int a;
  10. double licz = 0;
  11. srand(time(NULL));
  12.  
  13. for( a = 100 ; a < 10000 ; a = a + 100)
  14. {
  15.  
  16. int *tab=new int[a];
  17. for(int i=0; i<a; i++)
  18. {
  19. tab[i]=rand();
  20.  
  21. }
  22. int dom=0;
  23. int wart=0;
  24. licz+=4;
  25. for(int i=0; i<a; i++)
  26. {
  27. licz+=6;
  28. dom=0;
  29. wart=tab[i];
  30. for(int j=0; j<a; j++)
  31. {
  32. licz+=2;
  33. if(wart==tab[j])
  34. {
  35. dom++; licz++;
  36. }
  37. licz++;
  38.  
  39. }
  40. licz++;
  41.  
  42. }
  43.  
  44.  
  45. ofstream zapis("dane.txt", ios_base::app);
  46. zapis<<licz<<endl;
  47.  
  48. zapis.close();
  49.  
  50.  
  51. cout << " ilosc operacji dla tablicy; " << licz << endl;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement