Помощь с написанием фунцкии на c++

Всем привет, мне нужна помощь с написанием одной функции которая: выводит на экран информацию: о тех ДТП, в котором нарушителем была лицо с фамилией введенным с клавиатуры или сообщает об отсутствии таковых. Типа проверка на повторение фамилии. Вот мой целий код:

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int menu();
void Vvid_Dannyh();
void SortS();
void SortA();
void Display();
int Enter();
int Proc();
void GuGi();


int SIZE = 5;
const int N = 2;
int g = 0;

struct Data
{
    char InSur[20];
    char PoSur[20];
    char MiPod[40];
    int Shtraf;
} Spysok[N] ;

bool SortSetS(Data FirstP, Data SecondP)
{
    return (strcmp(FirstP.InSur, SecondP.InSur) < 0);
}

bool SortSetA(Data FirstA, Data SecondA)
{
    return (FirstA.Shtraf > SecondA.Shtraf);
}

void SortS()
{
    sort(Spysok, Spysok + N, SortSetS);
    Display();
}

void SortA()
{
    sort(Spysok, Spysok + N, SortSetA);
    Display();
}

void Display()
{
    GuGi();
    for (int i = 0; i < N; i++) {
        if (g = 1) {
            cout << "Ispector name: " << Spysok -> InSur << endl;
            cout << "Offer name: " << Spysok -> PoSur << endl;
            cout << "Venue: " << Spysok -> MiPod << endl;
            cout << "The amount of the fine: " << Spysok -> Shtraf << endl;
        }
        if (g = 0)
        {
            cout << "Ispector name: " << Spysok[i].InSur << endl;
            cout << "Offer name: " << Spysok[i].PoSur << endl;
            cout << "Venue: " << Spysok[i].MiPod << endl;
            cout << "The amount of the fine: " << Spysok[i].Shtraf << endl;
        }
    }
}

void GuGi()
{
    for (int i = 0; i < N; i++)
        if (Spysok[i].InSur == Spysok[i].InSur)
            g++;
}

void Perevirka()
{
    for (int i = 0; i < N; i++)
    {
        Spysok[i].Shtraf = 0;
    }
}

int main() {


    int i, j;

    Perevirka();
    Proc();
    

    return 0;
}


int Proc()
{
    char Vyb1;
    //menu();
    for (;;) {
        Vyb1 = menu();
        switch (Vyb1) {
            case 'e': Vvid_Dannyh();
                break;
            case 's': SortS();
                break;
            case 'a': SortA();
                break;
            case 'd': Display();
                break;
            case 'q': return 0;
        }
    }
return 0;
}


int menu() 
{
    char Vyb1;
    cout << '\n';
    do {
        cout << "(E)nter\n";
        cout << "Sort by (S)urname\n";
        cout << "Sort by (A)mount of the fine\n";
        cout << "(D)isplay\n";
        cout << "(Q)uit\n";
        cout << "Choose command: ";
        cin >> Vyb1;
    } while (!strchr("esadq", tolower(Vyb1)));
    return tolower(Vyb1);
}

void Vvid_Dannyh()
{

    int i = Enter();
    //int i = 0;
    if (i != -1) {

        cout << "Enter information about DTP: \n";
        cout << "\nInspector Surname: ";                cin >> Spysok[i].InSur;
        cout << "\nOffender surname: ";                 cin >> Spysok[i].PoSur;
        cout << "\nEnter venue: ";                      cin >> Spysok[i].MiPod;
        cout << "\nEnter the amount of the fine: ";     cin >> Spysok[i].Shtraf;
    }
}

int Enter() {
    int i;
    for (i = 0; i < N; i++)
        if (Spysok[i].Shtraf == 0) break;
    if (i == N) {
        cout << "List is full \n";
        i = -1;
    }
    return i;
}



Ответы (0 шт):