Advertisement
Nickolas_Amorgianos

Untitled

Dec 4th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6.  
  7.  
  8. int sindesi (char on[20],char kod[20]);
  9. int x;
  10. char user[20];
  11. char pass[20];
  12. char movie [20];
  13. int date=0;
  14. int room= (rand()%20 ) + 1;
  15. int room1=0;
  16. int i;
  17. int seats=0;
  18. int apth=5;
  19. int apad (void);
  20. int thesi=0;
  21. int kathismata[100];
  22. int j;
  23. int thesi2=0;
  24. int thesi3= (rand()%100 ) + 1;
  25. int poso=0;
  26.  
  27. int main ()
  28. {
  29. for ( j = 99 ; j >= 0; j--)
  30. {
  31. kathismata[j]=j+1;
  32. }
  33. do
  34. {
  35. printf ("username:\n");
  36. scanf (" %s", &user);
  37. printf ("password:\n");
  38. scanf (" %s", &pass);
  39. x=sindesi (user,pass);
  40. }
  41. while (x==0);
  42. printf ("oi diathesimes tainies einai:\n");
  43. printf ("i) Home Alone 3\nii) Ted 2\niii) Star wars episode 1\niv) Harry Potter 4\n");
  44. do
  45. {
  46. printf ("poia tainia epithimite na deite? grpase th prwth le3h tis tainias poy epithimite etsi akrivws opws emfanizetai stin othoni\n");
  47. scanf (" %s", &movie);
  48. }
  49. while ((strcmp(movie, "Home") == 1 ) && (strcmp(movie, "Ted") == 1 ) && (strcmp(movie, "Star") == 1 ) && (strcmp(movie, "Harry") == 1 ));
  50. do
  51. {
  52. printf ("poia mera epithimete na deite th tainia?\n");
  53. scanf (" %d", &date);
  54. }
  55. while ((date<0) || (date>24));
  56. printf ("\n\nh tainia tha provlithei sthn aithousa %d\n", room);
  57. printf ("epanalavete thn aithousa gia epivevaiwsh:\n");
  58. scanf (" %d", &room1);
  59. do
  60. {
  61. printf ("lathos aithousa, 3anaprospathieste:\n");
  62. scanf (" %d", &room1);
  63. }
  64. while (room1!=room);
  65. system("cls");
  66. printf ("oi diathesimes theseis einai:\n\n");
  67. for ( i = 100 ; i >0 ; i-- )
  68. {
  69. if (i==80)
  70. {
  71. printf ("\n\t");
  72. }
  73. if (i==65)
  74. {
  75. printf ("\n\t");
  76. }
  77. if (i==50)
  78. {
  79. printf ("\n\t");
  80. }
  81. if (i==35)
  82. {
  83. printf ("\n\t");
  84. }
  85. if (i==20)
  86. {
  87. printf ("\n\t\t");
  88. }
  89. if (i==10)
  90. {
  91. printf ("\n\t\t\t");
  92. }
  93. printf (" %d", i);
  94. }
  95. printf ("\nposes theseis thelete na krathsete?\n");
  96. scanf (" %d", &seats);
  97. while ((seats<0) || (seats>2))
  98. {
  99. printf ("de boreite na krathsete panw apo 2 theseis\ndwste egiro arithmo thesewn\n");
  100. scanf (" %d", &seats);
  101. }
  102. apth=apad ();
  103. while (apth==0)
  104. {
  105. apth=apad ();
  106. }
  107. if (apth==2)
  108. {
  109. if (seats==1)
  110. {
  111. printf ("se poia thesi epithimite na katsete?\n");
  112. scanf (" %d", &thesi);
  113. while ((thesi<1) || (thesi>100))
  114. {
  115. printf ("mi egiros arithos thesis, prospathiste 3ana\n");
  116. scanf (" %d", &thesi);
  117. }
  118. system ("cls");
  119. kathismata[thesi - 1 ]=0;
  120. printf ("seat is: %d\n", thesi);
  121. for ( j = 99 ; j >= 0; j--)
  122. {
  123. printf (" %d", kathismata[j]);
  124. }
  125. }
  126. else
  127. {
  128. printf ("se poia thesi epithimite na katsete?\n");
  129. scanf (" %d", &thesi);
  130. printf ("se poai thesi epithimite na katsei to allo atomo poy einai amzi sas\n");
  131. scanf (" %d", &thesi2);
  132. int k=thesi-thesi2;
  133. while ((k < -1) || (k > 1))
  134. {
  135. printf ("oi theseis poy dwsate den einai dipla h mia sthn allh, 3anadwste th prwth thesi\n");
  136. scanf (" %d", &thesi);
  137. printf ("3anadwste kai th deuterh thesi\n");
  138. scanf (" %d", &thesi2);
  139. }
  140. system ("cls");
  141. kathismata [thesi - 1]=0;
  142. kathismata [thesi - 2]=0;
  143. printf ("seats are: %d, %d", thesi, thesi2);
  144. for ( j = 99 ; j >= 0; j--)
  145. {
  146. printf (" %d", kathismata[j]);
  147. }
  148. }
  149. }
  150. else
  151. {
  152. if (seats==1)
  153. {
  154. system ("cls");
  155. kathismata[thesi3 - 1 ]=0;
  156. printf ("seat is: %d\n", thesi3);
  157. for ( j = 99 ; j >= 0; j--)
  158. {
  159. printf (" %d", kathismata[j]);
  160. }
  161. }
  162. else
  163. {
  164. system ("cls");
  165. kathismata [thesi3 - 1]=0;
  166. kathismata [thesi3]=0;
  167. int l=thesi3+1;
  168. printf ("seats are: %d, %d", thesi3, l);
  169. for ( j = 99 ; j >= 0; j--)
  170. {
  171. printf (" %d", kathismata[j]);
  172. }
  173. }
  174. }
  175. if (seats==1)
  176. {
  177. poso=10;
  178. }
  179. if (seats==2)
  180. {
  181. poso=15;
  182. }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. return 0;
  190. }
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. int sindesi (char on[20], char kod[20])
  200. {
  201. if ((strcmp(on, "movie") ==0 ) && (strcmp(kod, "mo") ==0 ))
  202. {
  203. return 1;
  204. }
  205. else
  206. {
  207. printf ("wrong data, try again\n");
  208. return 0;
  209. }
  210.  
  211. }
  212. int apad (void)
  213. {
  214. int k=5;
  215. char ap[2];
  216. printf ("pws thete na kratithoun oi theseis? pieste X gia xeirokinhta h A gia aytomata");
  217. scanf (" %s", &ap);
  218. if ((strcmp(ap, "A") ==0 ))
  219. {
  220. k=1;
  221. return 1;
  222.  
  223. }
  224. if ((strcmp(ap, "X") ==0 ))
  225. {
  226. k=2;
  227. return 2;
  228.  
  229. }
  230. if (k==5)
  231. {
  232. return 0;
  233. }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement