Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. #include <windows.h>
  5. #include <conio.h>
  6. #include "KeyboardControl.h"
  7.  
  8. using namespace std;
  9.  
  10.  
  11. float balance=500;
  12.  
  13.  
  14. int random_number ()
  15. {
  16. int num;
  17. rand();
  18. num = rand()%8784;
  19.  
  20. switch(num)
  21. {
  22. case 0 ... 615:
  23. {
  24. return 1;
  25. break;
  26. }
  27. case 616 ... 1231:
  28. {
  29. return 2;
  30. break;
  31. }
  32. case 1232 ... 1847:
  33. {
  34. return 3;
  35. break;
  36. }
  37. case 1848 ... 2463:
  38. {
  39. return 4;
  40. break;
  41. }
  42. case 2464 ... 3079:
  43. {
  44. return 5;
  45. break;
  46. }
  47. case 3080 ... 3695:
  48. {
  49. return 6;
  50. break;
  51. }
  52. case 3696 ... 4311:
  53. {
  54. return 7;
  55. break;
  56. }
  57. case 4312 ... 4927:
  58. {
  59. return 8;
  60. break;
  61. }
  62. case 4928 ... 5088:
  63. {
  64. return 0;
  65. break;
  66. }
  67. case 5089 ... 5704:
  68. {
  69. return 9;
  70. break;
  71. }
  72. case 5705 ... 6320:
  73. {
  74. return 10;
  75. break;
  76. }
  77. case 6321 ... 6936:
  78. {
  79. return 11;
  80. break;
  81. }
  82. case 6937 ... 7552:
  83. {
  84. return 12;
  85. break;
  86. }
  87. case 7553 ... 8168:
  88. {
  89. return 13;
  90. break;
  91. }
  92. case 8169 ... 8784:
  93. {
  94. return 14;
  95. break;
  96. }
  97. }
  98. }
  99.  
  100. float color_win(float bal,int y)
  101. {
  102. int x=15;
  103. int bet;
  104. int i;
  105.  
  106. do
  107. {
  108. cout<<"Podaj ile chcesz postawic: " ;
  109. cin>>bet;
  110. system("CLS");
  111. }while(bal<=bet);
  112.  
  113.  
  114.  
  115.  
  116. system("CLS");
  117. while(1)
  118. {
  119. i=0;
  120. char a;
  121.  
  122. gotoxy(1,1);
  123. cout<<"Na co chcesz postawic"<<endl;
  124. gotoxy(10,10);
  125. cout<<"1.Czerwone"<<endl;
  126. gotoxy(28,10);
  127. cout<<"2.Zielone"<<endl;
  128. gotoxy(45,10);
  129. cout<<"3.Czarne"<<endl;
  130. a=getch();
  131.  
  132. if((a==46) && (x != 49)) {
  133. gotoxy(x,12);
  134. cout << " ";
  135. x=x+17;
  136. gotoxy(x,12);
  137. cout << "^";
  138. i++;
  139. continue;
  140.  
  141. }
  142.  
  143. if((a==44) && (x != 15))
  144. {
  145. gotoxy(x,12);
  146. cout << " ";
  147. x=x-17;
  148. gotoxy(x,12);
  149. cout << "^";
  150. i--;
  151. continue;
  152. }
  153.  
  154. if(a==47)
  155. {
  156. bal=bal-bet;
  157.  
  158. if ((i==0)&&(y%2==0))
  159. {
  160. bal=bal+bet*2;
  161. return bal;
  162. }
  163. if ((i==2)&&(y%2==1))
  164. {
  165. bal=bal+bet*2;
  166. return bal;
  167. }
  168. if ((i==1)&&(y==0))
  169. {
  170. bal=bal+bet*14;
  171.  
  172. return bal;
  173.  
  174. }
  175. else
  176. {
  177. return bal;
  178. }
  179. }
  180.  
  181.  
  182.  
  183. }
  184. }
  185. void roll(int num)
  186. {
  187. int time;
  188. boolean info=false;
  189. time=35;
  190. int ilosc=0;
  191. gotoxy(9,5);
  192. for (int j=0;j<=14;j++)
  193. { if(j<10) cout<<char(201)<<char(205)<<char(187)<<" ";
  194. if(j>=10) cout<<char(201)<<char(205)<<char(205)<<char(187)<<" ";
  195. }
  196. gotoxy(9,6);
  197. for(int i=0;i<=14;i++)
  198. {
  199. cout<<char(186)<<i<<char(186)<<" ";
  200. }
  201. gotoxy(9,7);
  202. for(int k=0;k<=14;k++)
  203. {
  204. if(k<10) cout<<char(200)<<char(205)<<char(188)<<" ";
  205. if(k>=10) cout<<char(200)<<char(205)<<char(205)<<char(188)<<" ";
  206. }
  207. num=14;
  208.  
  209. while(info==false)
  210. {
  211. for(int x=0;x<=64;x++)
  212. {
  213. Sleep(time);
  214. gotoxy(x+9,9);
  215. cout<<" ^ ";
  216. if(x==64)
  217. {
  218. ilosc++;
  219. gotoxy(9+64,9);
  220. cout<<" ";
  221. x=0;
  222.  
  223. }
  224. if(ilosc==1) time=75;
  225. if ((ilosc==1)&&(num==0)&&(x==1))
  226. {
  227. time=0;
  228. info=true;
  229. break;
  230.  
  231. }
  232. if ((ilosc==1)&&(num==1)&&(x==5))
  233. {
  234. time=0;
  235. info=true;
  236. break;
  237. }
  238. if ((ilosc==1)&&(num==2)&&(x==9))
  239. {
  240. time=0;
  241. info=true;
  242. break;
  243. }
  244. if ((ilosc==1)&&(num==3)&&(x==13))
  245. {
  246. time=0;
  247. info=true;
  248. break;
  249. }
  250. if ((ilosc==1)&&(num==4)&&(x==17))
  251. {
  252. time=0;
  253. info=true;
  254. break;
  255. }
  256. if ((ilosc==1)&&(num==5)&&(x==21))
  257. {
  258. time=0;
  259. info=true;
  260. break;
  261. }
  262. if ((ilosc==1)&&(num==6)&&(x==25))
  263. {
  264. time=0;
  265. info=true;
  266. break;
  267. }
  268. if ((ilosc==1)&&(num==7)&&(x==29))
  269. {
  270. time=0;
  271. info=true;
  272. break;
  273. }
  274. if ((ilosc==1)&&(num==8)&&(x==33))
  275. {
  276. time=0;
  277. info=true;
  278. break;
  279. }
  280. if ((ilosc==1)&&(num==9)&&(x==37))
  281. {
  282. time=0;
  283. info=true;
  284. break;
  285. }
  286. if ((ilosc==1)&&(num==10)&&(x==41))
  287. {
  288. time=0;
  289. info=true;
  290. break;
  291. }
  292. if ((ilosc==1)&&(num==11)&&(x==45))
  293. {
  294. time=0;
  295. info=true;
  296. break;
  297. }
  298. if ((ilosc==1)&&(num==12)&&(x==49))
  299. {
  300. time=0;
  301. info=true;
  302. break;
  303. }
  304. if ((ilosc==1)&&(num==13)&&(x==53))
  305. {
  306. time=0;
  307. info=true;
  308. break;
  309. }
  310. if ((ilosc==1)&&(num==14)&&(x==62))
  311. {
  312. time=0;
  313. info=true;
  314. break;
  315. }
  316.  
  317. }
  318. }
  319. }
  320.  
  321.  
  322. int main()
  323. {
  324. srand( time( NULL ) );
  325. cout<<color_win(balance,random_number());
  326. //roll(random_number());
  327.  
  328.  
  329.  
  330. return 0;
  331. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement