Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. # include <iostream>
  2. #include <Windows.h>
  3. # define str_len 50
  4. # define size 10
  5. int choice;
  6. using namespace std;
  7. struct Custumer
  8. {
  9. char name[str_len];
  10. int account_number;
  11. int sum_on_account;
  12. unsigned short m : 4;
  13. unsigned short d : 4;
  14. unsigned short h : 4;
  15. unsigned short g : 7;
  16. };
  17. enum { preferential=1, urgent }type_account;
  18. struct Custumer list_of_custumers[size];
  19. Custumer bad;
  20. int current_size = 0;
  21. int month;
  22. int day;
  23. int hour;
  24. int type;
  25. int god;
  26. void enter_new()
  27. {
  28.  
  29. setlocale(LC_CTYPE, "Russian");
  30. cout << "Ввод информации " << endl;
  31. if (current_size < size)
  32. {
  33. cout << "Строка номер ";
  34. cout << current_size + 1;
  35. cout << endl << "Ф.И.О " << endl;
  36. cin >> list_of_custumers[current_size].name;
  37. cout << "Номер счета " << endl;
  38. cin >> list_of_custumers[current_size].account_number;
  39. cout << "Тип счета(1-preferential,2-urgent) " << endl;
  40. cin >> type;
  41. if (type == 1) {
  42. type_account = preferential; cout << "preferential" << endl;
  43. }
  44. else if (type == 2) {
  45. type_account = urgent; cout << "urgent" << endl;
  46. }
  47. cout << "Сумма на счете" << endl;
  48. cin >> list_of_custumers[current_size].sum_on_account;
  49. cout << "Дата изменения" << endl;
  50. cout << "Год: " << endl; cin >> month; list_of_custumers[current_size].g = god;
  51. cout << "Месяц: " << endl; cin >> month; list_of_custumers[current_size].m = month;
  52. cout << "День: " << endl; cin >> day; list_of_custumers[current_size].d =day;
  53. cout << "Час: " << endl; cin >> hour; list_of_custumers[current_size].h = hour;
  54. current_size++;
  55. }
  56. else cout << "Введено максимальное кол-во строк ";
  57. cout << "Что дальше? " << endl;
  58. cin >> choice;
  59. }
  60. void del()
  61. {
  62. setlocale(LC_CTYPE, "Russian");
  63. int d;
  64. cout << "\nНомер строки, которую надо удалить (для удаления всех строк нажать 99) " << endl;
  65. cin >> d;
  66. if (d != 99)
  67. {
  68. for (int de1 = (d - 1); de1 < current_size; de1++)
  69. list_of_custumers[de1] = list_of_custumers[de1 + 1];
  70. current_size = current_size - 1;
  71. }
  72. if (d == 99)
  73. for (int i = 0; i < size; i++)
  74. list_of_custumers[i] = bad;
  75. cout << "Что дальше?" << endl;
  76. cin >> choice;
  77. }
  78. void change()
  79. {
  80. int n, per,k;
  81. cout << "\nВведите номер строки" << endl;
  82. cin >> n;
  83. do
  84. {
  85. cout << "Введите: " << endl;
  86. cout << "1-Для изменения Ф.И.О" << endl;
  87. cout << "2-Для изменения номера счета" << endl;
  88. cout << "3-Для изменения типа счета" << endl;
  89. cout << "4-Для изменения суммы счета" << endl;
  90. cout << "5-Для изменения новая дата" << endl;
  91. cout << "6-конец\n"; cin >> per;
  92. switch (per)
  93. {
  94. case 1: cout << "Новое Ф.И.О";
  95. cin >> list_of_custumers[n - 1].name;
  96. break;
  97. case 2: cout << "Новый номер счета";
  98. cin >> list_of_custumers[n - 1].account_number;
  99. break;
  100. case 3: cout << "Новый тип счета"; cin >> k; k = type_account;
  101. break;
  102. case 4: cout << "Новая сумма"; cin >> list_of_custumers[n - 1].sum_on_account;
  103. break;
  104. case 5: cout << "Новая дата изменения"; /*cin >> list_of_custumers[n - 1].;*/
  105. break;
  106. }
  107. } while (per != 6);
  108. cout << "Что дальше?" << endl;
  109. cin >> choice;
  110. }
  111. void out()
  112. {
  113. setlocale(LC_CTYPE, "Russian");
  114. int sw, n, u;
  115. cout << "1-вывод по номеру" << endl;
  116. cout << "2-вывод по сумме в диапазоне" << endl;
  117. cin >> sw;
  118. if (sw == 1)
  119. {
  120. cout << "Введите номер счета" << endl;
  121. cin >> n;
  122. for (int i = 0; i < size; i++)
  123. {
  124. if (n == list_of_custumers[i].account_number)
  125. {
  126. cout << "Ф.И.О " << endl;;
  127. cout << list_of_custumers[i].name << endl;
  128. cout << "Номер счета " << endl;
  129. cout << list_of_custumers[i].account_number << endl;
  130. cout << "Тип счета " << endl;
  131. cout << "Тип счета(1-preferential,2-urgent) " << endl;
  132. if (type == 1) {
  133. type_account = preferential; cout << "preferential" << endl;
  134. }
  135. else if (type == 2) {
  136. type_account = urgent; cout << "urgent" << endl;
  137. }
  138. cout << "Сумма на счете " << endl;
  139. cout << list_of_custumers[i].sum_on_account << endl;
  140. cout << "Дата именения " << endl;
  141. cout << "Месяц: " << month << endl;
  142. cout << "День: " << day << endl;
  143. cout << "Час: " << hour << endl;
  144. }
  145. }
  146. }
  147. if (sw == 2)
  148. {
  149. cout << "Счета где сумма больше 100" << endl;
  150. for (int i = 0; i < size; i++)
  151. {
  152. if (list_of_custumers[i].sum_on_account >= 100)
  153. {
  154. cout << "Ф.И.О ";
  155. cout << list_of_custumers[i].name << endl;
  156. cout << "Номер счета " << endl;
  157. cout << list_of_custumers[i].account_number << endl;
  158. cout << "Тип счета " << endl;
  159. if (type == 1) {
  160. type_account = preferential; cout << "preferential" << endl;
  161. }
  162. else if (type == 2) {
  163. type_account = urgent; cout << "urgent" << endl;
  164. }
  165. cout << "Сумма на счете " << endl;
  166. cout << list_of_custumers[i].sum_on_account << endl;
  167. cout << "Дата именения " << endl;
  168. cout << "Месяц: " << month<< endl;
  169. cout << "День: "<< day<< endl;
  170. cout << "Час: " << hour<< endl;
  171. }
  172.  
  173. }
  174. cout << "Что дальше?" << endl; cin >> choice;
  175. }
  176.  
  177. }
  178. int main()
  179. {
  180. SetConsoleCP(1251);
  181. SetConsoleOutputCP(1251);
  182. setlocale(LC_CTYPE, "Russian");
  183. cout << "Введите:" << endl;
  184. cout << "1-для удаления записи" << endl;
  185. cout << "2-для ввода новой записи" << endl;
  186. cout << "3-для изменения записи" << endl;
  187. cout << "4-для вывода записи(ей)" << endl;
  188. cout << "5-для выхода" << endl;
  189. cin >> choice;
  190. do
  191. {
  192. switch (choice)
  193. {
  194. case 1: del();
  195. break;
  196. case 2: enter_new();
  197. break;
  198. case 3: change();
  199. break;
  200. case 4: out();
  201. break;
  202. }
  203. } while (choice != 5);
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement