fork(1) download
  1. #include <iostream>
  2. #include <time.h>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. int n;
  8. int *tablica;
  9. int najwieksza=0;
  10. int najmniejsza;
  11.  
  12. clock_t start,stop;
  13. double czas;
  14.  
  15. void sortowanie(int *tab, int n, int maximum, int minimum);
  16.  
  17. int main()
  18. {
  19. srand(time(NULL));
  20. cout<<"Ile losowych liczb chcesz posortowac: ";
  21. cin>>n;
  22. tablica = new int [n];
  23. for(int i=0; i<n; i++)
  24. {
  25. tablica[i] = rand()%100000+1;
  26. if(i==0)
  27. {
  28. najmniejsza = tablica[i];
  29. }
  30. if(tablica[i]>najwieksza)
  31. {
  32. najwieksza = tablica[i];
  33. }
  34. if(najmniejsza>tablica[i])
  35. {
  36. najmniejsza=tablica[i];
  37. }
  38. }
  39. start = clock();
  40. sortowanie(tablica, n, najwieksza, najmniejsza);
  41. stop = clock();
  42. czas = (double)(stop-start) / CLOCKS_PER_SEC;
  43. cout<<"Czas sortowania: "<<czas<<"s"<<endl;
  44. delete [] tablica;
  45. return 0;
  46. }
  47.  
  48. void sortowanie(int *tab, int n, int maximum, int minimum)
  49. {
  50. int miejsce=0;
  51. int bufor;
  52. for(int i=najmniejsza; i<=maximum; i++)
  53. {
  54. for(int j=0; j<n; j++)
  55. {
  56. if(tab[j]==i)
  57. {
  58. bufor = tab[miejsce];
  59. tab[miejsce] = tab[j];
  60. tab[j] = bufor;
  61. miejsce++;
  62. }
  63. }
  64. }
  65. }
  66.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:10: fatal error: windows.h: No such file or directory
 #include <windows.h>
          ^~~~~~~~~~~
compilation terminated.
stdout
Standard output is empty