Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6. int dfunction(int room[100],int s);
  7. void funcheck();
  8. int main() {
  9. int room[101];
  10. char movie[50];
  11. int i,showdt,clobby,j,seatres,pos;
  12. int lobby = 1 + rand() % 20;
  13.  
  14. printf("------------------------------------WELCOME-----------------------------------\n\n\n");
  15. printf(" Please Login\n");
  16. funcheck();
  17.  
  18. printf("\nDOCTOR STRANGE\nHACKSAW RIDGE\nUNDERWORLD: BLOOD WARS\nPETE'S DRAGON");
  19. do
  20. {
  21. printf("\n\nWhich movie you want to see?(enter the first word of thr movie) :");
  22. scanf("%s",&movie);
  23. }while (((strcmp(movie, "DOCTOR")!=0)) && ((strcmp(movie, "HACKSAW")!=0)) && ((strcmp(movie, "UNDERWORLD")!=0)) && ((strcmp(movie, "PETE")!=0)));
  24.  
  25.  
  26.  
  27.  
  28. do{
  29. printf("\n\nGive the day you want to watch the movie :");
  30. scanf("%d",&showdt);
  31. }while (showdt>24);
  32.  
  33. printf("\nThe available lobby for this movie is :%d",lobby);
  34. do
  35. {
  36. printf("\nPlease enter the number of the lobby that showed up for confirmation :");
  37. scanf("%d",&clobby);
  38. }while (clobby!=lobby);
  39.  
  40. system("cls");
  41. printf("Here you can see the availability of the seats:\n\n\n");
  42.  
  43. for(i=0;i<101;i++)
  44. {
  45. room[i]=i;
  46. }
  47. for(i=100;i>=0;i--)
  48. {
  49. if(room[i]<=100 && room[i]>=80)
  50. {
  51. printf("%d ",room[i]);
  52. }
  53.  
  54. else if(room[i]==79)
  55. {
  56. printf("\n %d ",room[i]);
  57. }
  58. else if(room[i]<79 && room[i]>=65)
  59. {
  60. printf("%d ",room[i]);
  61. }
  62. else if(room[i]==64)
  63. {
  64. printf("\n %d ",room[i]);
  65. }
  66.  
  67. else if(room[i]<64 && room[i]>=50)
  68. {
  69. printf("%d ",room[i]);
  70. }
  71. else if(room[i]==49)
  72. {
  73. printf("\n %d ",room[i]);
  74. }
  75. else if(room[i]<49 && room[i]>=35)
  76. {
  77. printf("%d ",room[i]);
  78. }
  79. else if(room[i]==34)
  80. {
  81. printf("\n %d ",room[i]);
  82. }
  83. else if(room[i]<35 && room[i]>=20)
  84. {
  85. printf("%d ",room[i]);
  86. }
  87. else if(room[i]==19)
  88. {
  89. printf("\n %d ",room[i]);
  90. }
  91. else if(room[i]<19 && room[i]>=10)
  92. {
  93. printf("%d ",room[i]);
  94. }
  95. else if(room[i]==9)
  96. {
  97. printf("\n %d ",room[i]);
  98. }
  99. else if(room[i]<9 && room[i]>=1)
  100. {
  101. printf("%d ",room[i]);
  102. }
  103.  
  104. }
  105. do
  106. {
  107. printf("\n\nFor how many seats you want to make a reservaration? :");
  108. scanf("%d",&seatres);
  109. }while ((seatres!=1) && (seatres!=2));
  110.  
  111. pos=dfunction(room,seatres);
  112. printf("\n\nseat(s) is :%d\n\n\n",pos);
  113.  
  114. /*NEOS PINAKAS*/
  115. for(i=100;i>=0;i--)
  116. {
  117. if(i<=100 && i>=80)
  118. {
  119. printf("%d ",room[i]);
  120. }
  121.  
  122. else if(i==79)
  123. {
  124. printf("\n %d ",room[i]);
  125. }
  126. else if(i<79 && i>=65)
  127. {
  128. printf("%d ",room[i]);
  129. }
  130. else if(i==64)
  131. {
  132. printf("\n %d ",room[i]);
  133. }
  134.  
  135. else if(i<64 && i>=50)
  136. {
  137. printf("%d ",room[i]);
  138. }
  139. else if(i==49)
  140. {
  141. printf("\n %d ",room[i]);
  142. }
  143. else if(i<49 && i>=35)
  144. {
  145. printf("%d ",room[i]);
  146. }
  147. else if(i==34)
  148. {
  149. printf("\n %d ",room[i]);
  150. }
  151. else if(i<35 && i>=20)
  152. {
  153. printf("%d ",room[i]);
  154. }
  155. else if(i==19)
  156. {
  157. printf("\n %d ",room[i]);
  158. }
  159. else if(i<19 && i>=10)
  160. {
  161. printf("%d ",room[i]);
  162. }
  163. else if(i==9)
  164. {
  165. printf("\n %d ",room[i]);
  166. }
  167. else if(i<9 && i>=1)
  168. {
  169. printf("%d ",room[i]);
  170. }
  171.  
  172. }
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180. return 0;
  181. }
  182.  
  183. void funcheck()
  184. {
  185. char name[50];
  186. char pass[50];
  187. int f;
  188. f=0;
  189. while (f!=1)
  190. {
  191.  
  192. if (((strcmp(name, "movie")==0) && (strcmp(pass, "mo")==0)))
  193. {
  194. f=1;
  195. }
  196.  
  197. else
  198. {
  199. printf("Username :");
  200. scanf("%s",&name);
  201. printf("Password :");
  202. scanf("%s",&pass);
  203. }
  204. }
  205. }
  206.  
  207.  
  208. int dfunction(int room[101],int s)
  209. {
  210. int seatnum,seatnum2,mid,mid2;
  211. int lk = 1 + rand() % 100;
  212. char chs[10];
  213. do{
  214. printf("\nIn which way you want to choose seats(Press 'X' for manual way or 'A' for automatic way) :");
  215. scanf("%s", &chs);
  216. }while ((strcmp(chs, "A")!=0) && (strcmp(chs, "X")!=0));
  217.  
  218. if (strcmp(chs, "X")==0)
  219. {
  220. if(s==1)
  221. {
  222. printf("\n\nType the number of the seat(s) you want :");
  223. scanf("%d", &seatnum);
  224. room[seatnum]=0;
  225. }
  226. else if(s==2)
  227. {
  228. printf("\n\nType the number of the seat(s) you want :");
  229. printf("\nSeat number 1 :");
  230. scanf("%d", &seatnum);
  231. room[seatnum]=0;
  232.  
  233. printf("\nSeat number 2 :");
  234. scanf("%d",&seatnum2);
  235. mid=seatnum+1;
  236. mid2=seatnum-1;
  237. if ((seatnum>=100 && seatnum<=81) || (seatnum>=79 && seatnum<=66) || (seatnum>=64 && seatnum<=51) || (seatnum>=49 && seatnum<=36) || (seatnum>=34 && seatnum<=21) || (seatnum>=19 && seatnum<=11) || (seatnum>=9 && seatnum<=2))
  238. {
  239. do
  240. {
  241. printf("\nSeat number 2 :");
  242. scanf("%d",&seatnum2);
  243. }while((seatnum2!=mid2) && (seatnum2!=mid));
  244. }
  245. else if ((seatnum==80) || (seatnum==65) || (seatnum==50) || (seatnum==35) || (seatnum==20) || (seatnum==10) || (seatnum==1))
  246. {
  247. do
  248. {
  249. printf("\nSeat number 2 :");
  250. scanf("%d",&seatnum2);
  251. }while (seatnum2!=mid);
  252. }
  253. else if ((seatnum==100) || (seatnum==79) || (seatnum==64) || (seatnum==49) || (seatnum==34) || (seatnum==19) || (seatnum==9))
  254. {
  255. do
  256. {
  257. printf("\nSeat number 2 :");
  258. scanf("%d",&seatnum2);
  259. }while (seatnum2!=mid2);
  260. }
  261. }
  262. room[seatnum2]=0;
  263. }
  264. else if(strcmp(chs, "A")==0)
  265. {
  266. if(s==1)
  267. {
  268. seatnum=lk;
  269. printf("\nSeat number :%d\n",seatnum);
  270. room[seatnum]=0;
  271. }
  272. else if(s==2)
  273. {
  274. seatnum=lk;
  275. printf("\nSeat number 1:%d",seatnum);
  276. room[seatnum]=0;
  277. if ((seatnum<=100 && seatnum>=81) || (seatnum<=79 && seatnum>=66) || (seatnum<=64 && seatnum>=51) || (seatnum<=49 && seatnum>=36) || (seatnum<=34 && seatnum>=21) || (seatnum<=19 && seatnum>=11) || (seatnum<=9 && seatnum>=2))
  278. {
  279. seatnum2=seatnum+1;
  280. printf("\nSeat number 2:%d",seatnum2);
  281. room[seatnum2]=0;
  282. }
  283. else if ((seatnum==80) || (seatnum==65) || (seatnum==50) || (seatnum==50) || (seatnum==35) || (seatnum==20) || (seatnum==10) || (seatnum==1))
  284. {
  285. seatnum2=seatnum-1;
  286. printf("\nSeat number 2:%d",seatnum2);
  287. room[seatnum]=0;
  288. }
  289. else if ((seatnum==100) || (seatnum==79) || (seatnum==64) || (seatnum==49) || (seatnum==34) || (seatnum==19) || (seatnum==9))
  290. {
  291. seatnum2=seatnum+1;
  292. printf("\nSeat number 2:%d",seatnum2);
  293. room[seatnum2]=0;
  294. }
  295. }
  296. }
  297.  
  298. return seatnum;
  299. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement