fork download
  1. #include <iostream>
  2. #include <Windows.h>
  3. void main()
  4. {
  5. std::cout<<"Czy wykonac rzut?\n"
  6. <<"Podaj liczbę oczek.";
  7. int oczka;
  8. std::cin>oczka;
  9.  
  10. switch(oczka)
  11. {
  12. case 1:
  13. std::cout<<"1\n";
  14. break;
  15. case 2:
  16. std::cout<<"2\n";
  17. break;
  18. case 3:
  19. std::cout<<"3\n";
  20. break;
  21. case 4:
  22. std::cout<<"4\n";
  23. break;
  24. case 5:
  25. std::cout<<"5\n";
  26. break;
  27. case 6:
  28. std::cout<<"6\n";
  29. break;
  30.  
  31. default:
  32. std::cout<<"Podales liczbe oczek:"<<czka<<"-nie probuj mnie przechytrzyc!/n";
  33. }
  34. system("pause");
  35.  
  36.  
  37. }
  38.  
  39.  
  40.  
  41. //int main(void)
  42. {
  43. int i;
  44. time_t t;
  45.  
  46. srand((unsigned) time(&t));
  47. printf("Numer od 1 do 6\n\n");
  48. for(i=0; i<6; i++)
  49. printf("%d\n", rand() % 6);
  50. return ;
  51. }
  52.  
  53.  
  54.  
  55. k=rand()%nn+1;
  56. los[ 0]=k;
  57.  
  58.  
  59.  
  60. #include <iostream>
  61. #include <time.h>
  62. #include <cassert>
  63. #include <cstdlib>
  64. #include <Windows.h>
  65. int main()
  66. {
  67. int iloscLosow = 0, zakres = 0;
  68.  
  69. std::cout << "podaj ilosc losowanych liczb ";
  70. std::cin > iloscLosow;
  71.  
  72. std::cout << std::endl << "podaj z ilu liczb losujesz ";
  73. std::cin > zakres;
  74.  
  75. srand(static_cast<unsigned int>time(0)));
  76.  
  77. for (short int i = 0; i < iloscLosow; i++)
  78. {
  79.  
  80. int l = 1 + rand() % zakres;
  81.  
  82. std::cout << "Los numer "<< i+1 << " jest rowny " << l << std::endl;
  83. while (l == zakres)
  84. {
  85. std::cout << "Wyrzucono " << l << ", uprawnienie do kolejnego rzutu: " << std::endl;
  86. l = 1 + rand() % zakres;
  87. std::cout << "Wylosowana liczba to: " << l << std::endl;
  88. }
  89. std::cout << std::endl;
  90. }
  91.  
  92. system ("pause");
  93. return 0;
  94. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:22: error: Windows.h: No such file or directory
prog.cpp:3: error: ‘::main’ must return ‘int’
prog.cpp: In function ‘int main()’:
prog.cpp:8: error: no match for ‘operator>’ in ‘std::cin > oczka’
prog.cpp:32: error: ‘czka’ was not declared in this scope
prog.cpp:34: error: ‘system’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:42: error: expected unqualified-id before ‘{’ token
prog.cpp:55: error: expected constructor, destructor, or type conversion before ‘=’ token
prog.cpp:56: error: expected constructor, destructor, or type conversion before ‘=’ token
prog.cpp: In function ‘int main()’:
prog.cpp:65: error: redefinition of ‘int main()’
prog.cpp:3: error: ‘int main()’ previously defined here
prog.cpp:70: error: no match for ‘operator>’ in ‘std::cin > iloscLosow’
prog.cpp:73: error: no match for ‘operator>’ in ‘std::cin > zakres’
prog.cpp:75: error: expected `(' before ‘time’
prog.cpp:92: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
stdout
Standard output is empty