fork download
  1. #include <iostream>
  2. #include <time.h>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6. clock_t start,stop;
  7. double czas;
  8.  
  9. int GRA(int a, int b)
  10. {
  11. if (a==b) return a+b;
  12. else if ((a==1)||(b==1)) return 2;
  13. else if ((a==2)&&(b%2==0)) return 4;
  14. else if ((a==2)&&(b%2==1)) return 2;
  15. else if ((b==2)&&(a%2==0)) return 4;
  16. else if ((b==2)&&(a%2==1)) return 2;
  17. else if (a<b)
  18. {
  19. b=b-a;
  20. return GRA(a,b);
  21. }
  22. else if (a>b)
  23. {
  24. a=a-b;
  25. return GRA(a,b);
  26. }
  27. }
  28.  
  29. int main()
  30. {
  31. int ile_testow;
  32. // int GRACZ_A=0, GRACZ_B=0;
  33. cout<<"ile testow"<<endl;
  34. cin>>ile_testow;
  35. int *tablica_a;
  36. tablica_a=new int [ile_testow];
  37. int *tablica_b;
  38. tablica_b = new int[ile_testow];
  39.  
  40. //inicjowanie generatora
  41.  
  42. srand(time(NULL));
  43.  
  44. //wczytywanie losowych liczb do tablicy1
  45. for (int i=0; i<ile_testow; i++)
  46. {
  47. tablica_a[i] = rand()%10000+1;
  48. }
  49. for (int i=0; i<ile_testow; i++)
  50. {
  51. tablica_b[i] = rand()%10000+1;
  52. }
  53.  
  54. start = clock();
  55.  
  56. for (int i=0; i<ile_testow; i++)
  57. {
  58. //cout<<"GRACZ_A: "<<tablica_a[i]<<" "<<"GRACZ_B: "<<tablica_b[i]<<endl;
  59. //cout<<
  60. GRA(tablica_a[i], tablica_b[i]);
  61. //<<endl;
  62. }
  63. stop = clock();
  64. czas = (double)(stop-start)/CLOCKS_PER_SEC;
  65. cout <<endl<<endl<<endl<<"CZAS OBROBIENIA "<<ile_testow<<" gier "<<czas<< " s"<<endl;
  66. delete [] tablica_a;
  67. delete [] tablica_b;
  68.  
  69. return 0;
  70.  
  71. }
  72.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2500000
compilation info
prog.cpp:3:21: fatal error: windows.h: No such file or directory
 #include <windows.h>
                     ^
compilation terminated.
stdout
Standard output is empty