Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cstring>
- using namespace std;
- const int kolichestvo = 2;
- const int D = 3;
- const int n = 2;
- struct ZNAK {
- char name[20];
- char surname[30];
- string znak;
- int date[D];
- };
- void meny(int &n);
- void fank2(int *A);
- void search(ZNAK *m, const int kolichestvo);
- void fank(ZNAK *A,const int n);
- void fillstruct(ZNAK *m, const int kolichestvo, const int D);
- void showstruct(ZNAK *m, const int kolichestvo, const int D);
- int main(){
- setlocale(LC_ALL, "rus");
- int choice = 0;
- ZNAK m[kolichestvo];
- //fillstruct(m, kolichestvo, D);
- //meny(choice);
- while (choice != 4) {
- // cin >> choice;
- meny(choice);
- if (choice == 1) {
- fillstruct(m, kolichestvo, D);
- fank(m, n);
- }
- 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 << "Завершение программы...";
- }
- 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 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 fank2(int *A) {
- for (int i=0; i < 3; i++) {
- cin >> A[i];
- }
- }
- void fank(ZNAK *A,const int n)
- {
- ZNAK P;
- for(int i=0;i<n;i++){
- for (int j = 0; j < n; j++) {
- if (A[i].date[3] > A[j].date[3]||
- (A[i].date[3] == A[j].date[3]&& A[i].date[2] > A[j].date[2])||
- (A[i].date[3] == A[j].date[3] && A[i].date[2] == A[j].date[2]&& A[i].date[1] > A[j].date[1])) {
- P = A[j];
- A[j] = A[i];
- A[i] = P;
- }
- }
- }
- }
- /*void search(ZNAK *m, const int kolichestvo){
- char surname_temp[20];
- int temp = 0;
- cout << "input surname temp: " << endl;
- cin.getline(surname_temp, 20);
- for(int i = 0; i < kolichestvo; i++){
- if (m[i].surname == surname_temp) {
- cout << m[i].name << " "<< m[i].surname << endl << m[i].znak << endl;
- for (int j = 0; j < 3; j++){
- cout << m[i].date[j] << " ";
- }
- cout << endl;
- break;
- }
- temp ++;
- }
- if (temp == kolichestvo) cout << " no pearsons " << endl;
- }*/
- void search(ZNAK *m, const int kolichestvo){
- char surname1[20];
- for ( int l = 0; l < 20; l++ )
- surname1[l]=NULL;
- cout<<"Enter needed surname: ";
- cin >> surname1;
- bool r = false;
- for ( int k = 0; k < kolichestvo; k++ )
- {
- bool b = true;
- int l = 0;
- while ( surname1[l] != NULL)
- { if (surname1[l] != m[k].surname[l]) b = false; l++;
- }
- if (surname1[l] != m[k].surname[l]) b = false;
- if ( b == true )
- {
- cout << m[k].name << " " << m[k].surname << endl << m[k].znak << endl;
- for (int j = 0; j < 3; j++){
- cout << m[k].date[j] << " ";
- }
- cout << endl;
- cout<<"--------------------------------------------------"<<endl;
- r = true;
- }
- }
- if ( r == false ) cout<<"No match person"<<endl;
- system("pause");
- }
Add Comment
Please, Sign In to add comment