Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <clocale>
- #include <fstream>
- using namespace std;
- const int D = 3;
- const int kolichestvo = 2;
- const int n = 2;
- struct ZNAK
- {
- char name[40];
- char surname[30];
- char znak[20];
- int date;
- };
- void fillstruct(ZNAK *m, const int kolichestvo, const int D);
- void meny(int &n);
- void search(ZNAK *m, const int kolichestvo);
- void fank2(int *A);
- int main(void) {
- setlocale(0, "ru");
- int choice = 0;
- ZNAK m[kolichestvo];
- //int i, j, kol = 4;
- ofstream fout("znak.txt", ios_base::app);
- while (choice != 4) {
- meny(choice);
- if (choice == 1) {
- fillstruct(m, kolichestvo, D);
- fout.open("znak.txt", ios_base::app);
- }
- if (choice == 3) {
- for (int i = 0; i < n; i++) {
- cout << m[i].name << " ";
- cout << m[i].surname << " "<<endl;
- cout << m[i].znak << endl;
- for (int j = 0; j < 3; j++) {
- cout << m[i].date[j] << " ";
- }
- cout << endl;
- }
- }
- if (choice == 2) {
- search(m, kolichestvo);
- system ("pause");
- }
- if (choice == 4) break;
- }
- cout << "Завершение программы...";
- fout.close();
- }
- void fank2(int *A) {
- for (int i=0; i < 3; i++) {
- cin >> A[i];
- }
- }
- void fillstruct(ZNAK *m, const int kolichestvo, const int D){
- for (int i = 0; i < kolichestvo; i++){
- cout << "input name and surname: ";
- cin >> m[i].name;
- cin >> m[i].surname;
- cout << "input Zodiac sign: ";
- cin >> m[i].znak;
- cout << "input date: ";
- fank2(m[i].date);
- }
- }
- void meny(int &n) {
- system("cls");
- cout << setw(15) << "****Меню****"<<endl<<endl;
- cout << setw(3) << "1) Ввести данные" << endl;
- cout << setw(3) << "2) найти человека " << endl;
- cout << setw(3) << "3) Вывести данные" << endl;
- cout << setw(3) << "4) Выход" << endl;
- cin >> n;
- }
- void search(ZNAK *m, const int kolichestvo){
- char surname2[40];
- cout << "input surname2: " << endl;
- cin >> surname2;
- bool f = false;
- for (int i = 0; i < kolichestvo; i++){
- if (strcmp(m[i].surname, surname2) == 0)
- {
- cout << m[i].name << " ";
- cout << m[i].surname << " "<<endl;
- cout << m[i].znak << endl;
- for (int j = 0; j < 3; j++) {
- cout << m[i].date[j] << " ";
- }
- cout << endl; }
- if (!f) {
- cout << "no pearson! " << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement