fork(1) download
  1. #include <stdio.h>
  2. //#include <conio.h>
  3. #include <stdlib.h>
  4. void input_data(void);
  5. void output_data(void);
  6. void change_data();
  7. void print(int);
  8. void search_data();
  9. void finish_application(void);
  10. int i;
  11. struct touring
  12. {char country[100];
  13. char city[100];
  14. int tour_duration;
  15. int cost;
  16. } tour[100];
  17. int main()
  18. //void main (void)
  19. {
  20. int p;
  21. printf("Welcome to Data Base of travel company King of World \n");
  22. while(1)
  23. {
  24. printf("Enter 1 if you want to enter data \n");
  25. printf("Enter 2 if you want to look at data\n");
  26. printf("Enter 3 if you want to change at data\n");
  27. printf("Enter 4 if you want to search data\n");
  28. printf("Enter 5 if you want to finish work with application\n");
  29. printf("Select:");
  30. scanf("%d",&p);
  31. switch(p)
  32. {
  33. case 1 :
  34. input_data();
  35. break;
  36. case 2:
  37. output_data();
  38. break;
  39. case 3:
  40. change_data();
  41. break;
  42. case 4:
  43. search_data();
  44. break;
  45. case 5:
  46. finish_application();
  47. break;
  48. default: printf("\n\t Any of points isn't chosen\n");
  49. }
  50.  
  51. }
  52. return 0;
  53. }
  54. void input_data(void)
  55. {
  56. for(i=0;i<3;i++)
  57. {printf("Enter data about %d' tour\n",i);
  58. printf("Enter country:");
  59. scanf("%s",tour[i].country);
  60. printf("Enter city:");
  61. scanf("%s",tour[i].city);
  62. printf("Enter number of days of tour:");
  63. scanf("%d",&tour[i].tour_duration);
  64. printf("Enter cost:");
  65. scanf("%d",&tour[i].cost);
  66. printf("\n");
  67. printf("\n");
  68. }
  69. }
  70. void change_data()
  71. {
  72. int a;
  73. printf("Enter number of record\n");
  74. scanf("%d",&i);
  75. printf("Select item for change\n");
  76. printf("1.country\n");
  77. printf("2.city\n");
  78. printf("3.numbers of days\n");
  79. printf("4.cost\n");
  80. scanf("%d", &a);
  81. switch (a)
  82. {
  83. case 1: {
  84. printf("Enter new country\n");
  85. scanf("%s", tour[i].country);
  86. break;
  87. }
  88. case 2: {
  89. printf("Enter new city\n");
  90. scanf("%s", tour[i].city);
  91. break;
  92. }
  93. case 3: {
  94. printf("Enter new numbers of days\n");
  95. scanf("%d", &tour[i].tour_duration);
  96.  
  97. break;
  98. }
  99. case 4: {
  100. printf("Enter new cost\n");
  101. scanf("%d", &tour[i].cost);
  102.  
  103. break;
  104. }
  105. }
  106. }
  107. void output_data(void)
  108. {for(i=0;i<3;i++)
  109. {printf("Data about %d' tour\n",i);
  110. printf("Country:%s\n",tour[i].country);
  111. printf("City:%s\n",tour[i].city);
  112. printf("Number of days of tour:%d\n",tour[i].tour_duration);
  113. printf("Cost:%d\n",tour[i].cost);
  114. printf("\n");
  115. printf("\n");
  116. }
  117. }
  118. void print(int i)
  119. {
  120. printf("Data about %d' tour\n",i);
  121. printf("Country:%s\n",tour[i].country);
  122. printf("City:%s\n",tour[i].city);
  123. printf("Number of days of tour:%d\n",tour[i].tour_duration);
  124. printf("Cost:%d\n",tour[i].cost);
  125. }
  126. void search_data()
  127. {
  128. int n=0;
  129. int i=0;
  130. int d=1;
  131. char b[100];
  132. printf("Enter 1 for search by country\n");
  133. printf("Enter 2 for search by city\n");
  134. printf("Enter 3 for search by number of days of tour\n");
  135. printf("Enter 4 for search by cost of tour\n");
  136. scanf("%d",&n);
  137. switch(n)
  138. {
  139. case 1:
  140. {
  141. printf("Enter country \n");
  142. scanf("%s",b);
  143. for(i=0;i<3;i++)
  144. if((tour[i].country==b))
  145. print(i);
  146. break;
  147. }
  148. case 2 :
  149. {
  150. printf("Enter city \n");
  151. scanf("%s",b);
  152. for(i=0;i<3;i++)
  153. if((tour[i].city==b))
  154. print(i);
  155. break;
  156. }
  157. case 3 :
  158. {
  159. printf("Enter number of days of tour \n");
  160. scanf("%d",&d);
  161. for(i=0;i<3;i++)
  162. if(tour[i].tour_duration==d)
  163. print(i);
  164. break;
  165. }
  166. case 4 :
  167. {
  168. printf("Enter cost of tour \n");
  169. scanf("%d",&d);
  170. for(i=0;i<3;i++)
  171. if(tour[i].cost==d)
  172. print(i);
  173. break;
  174. }
  175. }
  176. }
  177.  
  178.  
  179. void finish_application()
  180. {
  181. exit(1);
  182. }
  183.  
Runtime error #stdin #stdout 0s 2320KB
stdin
1  
russia moscow 5 500
usa vashington 1 100
gb london 2 200
2
4 
3 3
5
stdout
Welcome to Data Base of travel company King of World 
Enter 1 if you want to enter data 
Enter 2 if you want to look at data
Enter 3 if you want to change at data
Enter 4 if you want to search data
Enter 5 if you want to finish work with application
Select:Enter data  about 0' tour
Enter country:Enter city:Enter number of days of tour:Enter cost:

Enter data  about 1' tour
Enter country:Enter city:Enter number of days of tour:Enter cost:

Enter data  about 2' tour
Enter country:Enter city:Enter number of days of tour:Enter cost:

Enter 1 if you want to enter data 
Enter 2 if you want to look at data
Enter 3 if you want to change at data
Enter 4 if you want to search data
Enter 5 if you want to finish work with application
Select:Data about 0' tour
Country:russia
City:moscow
Number of days of tour:5
Cost:500


Data about 1' tour
Country:usa
City:vashington
Number of days of tour:1
Cost:100


Data about 2' tour
Country:gb
City:london
Number of days of tour:2
Cost:200


Enter 1 if you want to enter data 
Enter 2 if you want to look at data
Enter 3 if you want to change at data
Enter 4 if you want to search data
Enter 5 if you want to finish work with application
Select:Enter 1 for search by country
Enter 2 for search by city
Enter 3 for search by number of days of tour
Enter 4 for search by cost of tour
Enter number of days of tour 
Enter 1 if you want to enter data 
Enter 2 if you want to look at data
Enter 3 if you want to change at data
Enter 4 if you want to search data
Enter 5 if you want to finish work with application
Select: