mashlukashova

Untitled

Mar 22nd, 2019
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <clocale>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7. const int D = 3;
  8. const int kolichestvo = 2;
  9. const int n = 2;
  10. struct ZNAK
  11. {
  12.  
  13. char name[40];
  14. char surname[30];
  15. char znak[20];
  16. int date;
  17. };
  18.  
  19. void fillstruct(ZNAK *m, const int kolichestvo, const int D);
  20. void meny(int &n);
  21. void search(ZNAK *m, const int kolichestvo);
  22. void fank2(int *A);
  23.  
  24. int main(void) {
  25. setlocale(0, "ru");
  26. int choice = 0;
  27. ZNAK m[kolichestvo];
  28. //int i, j, kol = 4;
  29.  
  30. ofstream fout("znak.txt", ios_base::app);
  31.  
  32. while (choice != 4) {
  33.  
  34. meny(choice);
  35. if (choice == 1) {
  36. fillstruct(m, kolichestvo, D);
  37. fout.open("znak.txt", ios_base::app);
  38. }
  39.  
  40.  
  41. if (choice == 3) {
  42. for (int i = 0; i < n; i++) {
  43. cout << m[i].name << " ";
  44. cout << m[i].surname << " "<<endl;
  45. cout << m[i].znak << endl;
  46. for (int j = 0; j < 3; j++) {
  47. cout << m[i].date[j] << " ";
  48. }
  49. cout << endl;
  50. }
  51.  
  52. }
  53. if (choice == 2) {
  54. search(m, kolichestvo);
  55. system ("pause");
  56. }
  57. if (choice == 4) break;
  58. }
  59. cout << "Завершение программы...";
  60.  
  61. fout.close();
  62. }
  63.  
  64.  
  65. void fank2(int *A) {
  66. for (int i=0; i < 3; i++) {
  67. cin >> A[i];
  68. }
  69. }
  70.  
  71. void fillstruct(ZNAK *m, const int kolichestvo, const int D){
  72. for (int i = 0; i < kolichestvo; i++){
  73. cout << "input name and surname: ";
  74. cin >> m[i].name;
  75. cin >> m[i].surname;
  76.  
  77. cout << "input Zodiac sign: ";
  78. cin >> m[i].znak;
  79.  
  80. cout << "input date: ";
  81. fank2(m[i].date);
  82. }
  83. }
  84. void meny(int &n) {
  85. system("cls");
  86. cout << setw(15) << "****Меню****"<<endl<<endl;
  87. cout << setw(3) << "1) Ввести данные" << endl;
  88. cout << setw(3) << "2) найти человека " << endl;
  89. cout << setw(3) << "3) Вывести данные" << endl;
  90. cout << setw(3) << "4) Выход" << endl;
  91. cin >> n;
  92. }
  93.  
  94. void search(ZNAK *m, const int kolichestvo){
  95. char surname2[40];
  96. cout << "input surname2: " << endl;
  97. cin >> surname2;
  98. bool f = false;
  99. for (int i = 0; i < kolichestvo; i++){
  100. if (strcmp(m[i].surname, surname2) == 0)
  101. {
  102. cout << m[i].name << " ";
  103. cout << m[i].surname << " "<<endl;
  104. cout << m[i].znak << endl;
  105. for (int j = 0; j < 3; j++) {
  106. cout << m[i].date[j] << " ";
  107. }
  108. cout << endl; }
  109. if (!f) {
  110. cout << "no pearson! " << endl;
  111. }
  112. }
RAW Paste Data