fork download
  1. #include <iostream>
  2.  
  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. int main()
  65. {
  66. int iloscLosow = 0, zakres = 0;
  67.  
  68. std::cout << "podaj ilosc losowanych liczb ";
  69. std::cin > iloscLosow;
  70.  
  71. std::cout << std::endl << "podaj z ilu liczb losujesz ";
  72. std::cin > zakres;
  73.  
  74. srand(static_cast<unsigned int>time(0)));
  75.  
  76. for (short int i = 0; i < iloscLosow; i++)
  77. {
  78.  
  79. int l = 1 + rand() % zakres;
  80.  
  81. std::cout << "Los numer "<< i+1 << " jest rowny " << l << std::endl;
  82. while (l == zakres)
  83. {
  84. std::cout << "Wyrzucono " << l << ", uprawnienie do kolejnego rzutu: " << std::endl;
  85. l = 1 + rand() % zakres;
  86. std::cout << "Wylosowana liczba to: " << l << std::endl;
  87. }
  88. std::cout << std::endl;
  89. }
  90.  
  91. system ("pause");
  92. return 0;
  93. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
2
10
42
11
compilation info
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:64: error: redefinition of ‘int main()’
prog.cpp:3: error: ‘int main()’ previously defined here
prog.cpp:69: error: no match for ‘operator>’ in ‘std::cin > iloscLosow’
prog.cpp:72: error: no match for ‘operator>’ in ‘std::cin > zakres’
prog.cpp:74: error: expected `(' before ‘time’
prog.cpp:91: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
stdout
Standard output is empty