Program sortowanie danych

0

Cześć to znowu ja stworzyłem taki mały program który wyświetla mi dany zbiór z wartościami po wpisaniu odpowiedniej liczby mam pytanie da się to jakoś uprościć może wstawić w pętle albo zrobić jakieś zaawansowane wyszukiwanie tutaj daje mój program oczywiście program działa więc można zobaczyć o co mi chodzi

/*
Banshee	|EMF-5|Temperatura|Odciski|
Demon |Temperatura|Krótkofalówka|Książka
Mare |Temperatura|Orb|Krótkofalówka|
Spirit |Krótkofalówka|Książka|Odciski|
Poltergeist |Krótkofalówka|Odciski|Orb|
Jinn |EMF-5|Orb|Krótkofalówka|
Shade |EMF-5|Książka|Orb|
Yurei |Temperatura|Orb|Książka|
Oni |EMF-5|Książka|Krótkofalówka|
Revenant |EMF-5|Książka|Odciski|
Phantom |Temperatura|Orb|EMF-5|
Wendiego |Temperatura|Krótkofalówka|Odciski|
*/
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

struct Menu
{string duchy,opcje;}Wybor[]
{
/*0*/    {"Banshee","Orb",},
/*1*/    {"Demon","Spirit Box",},
/*2*/    {"Mare","EMF-5",},
/*3*/    {"Spirit","Finger Prints",},
/*4*/    {"Poltergeist","Writing",},
/*5*/    {"Jinn","Frezzing",},
/*6*/    {"Shade",},
/*7*/    {"Yurei",},
/*8*/    {"Oni"},
/*9*/    {"Revenant"},
/*10*/    {"Phantom"},
/*11*/    {"Wendiego"},
};

int Wybierz,Wybierz2,Wybierz3;
int main()
{
    cout<<"| Wybierz opcję: "<<endl;
    cout<<"|    1."<<Wybor[0].opcje<<endl;
    cout<<"|    2."<<Wybor[1].opcje<<endl;
    cout<<"|    3."<<Wybor[2].opcje<<endl;
    cout<<"|    4."<<Wybor[3].opcje<<endl;
    cout<<"|    5."<<Wybor[4].opcje<<endl;
    cout<<"|    6."<<Wybor[5].opcje<<endl;
    cout<<"... ";
    cin>>Wybierz;
    
    Orb:
    if(Wybierz==1)
    {
        cout<<endl<<"| Duchy:"<<endl;
        cout<<"|    1."<<Wybor[2].duchy<<endl;
        cout<<"|    2."<<Wybor[4].duchy<<endl;
        cout<<"|    3."<<Wybor[5].duchy<<endl;
        cout<<"|    4."<<Wybor[6].duchy<<endl;
        cout<<"|    5."<<Wybor[7].duchy<<endl;
        cout<<"|    6."<<Wybor[10].duchy<<endl<<endl;
            cout<<"| Wybierz opcję: "<<endl;
            cout<<"|    1."<<Wybor[1].opcje<<endl;
            cout<<"|    2."<<Wybor[2].opcje<<endl;
            cout<<"|    3."<<Wybor[3].opcje<<endl;
            cout<<"|    4."<<Wybor[4].opcje<<endl;
            cout<<"|    5."<<Wybor[5].opcje<<endl;
            cout<<"... ";
            cin>>Wybierz2;
            
            Orb_SpiritBox:
            if(Wybierz2==1)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[2].duchy<<endl;
                cout<<"|    2."<<Wybor[5].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[2].opcje<<endl;
                    cout<<"|    2."<<Wybor[5].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    Orb_SpiritBox_EMF5:
                    if(Wybierz3==1)
                    {
                            cout<<endl<<"Duch nazywa się: "<<Wybor[2].duchy<<endl;
                    };
                    
                    Orb_SpiritBox_Frezzing:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[5].duchy<<endl<<endl;
                    };
            };
            Orb_EMF5:
            if(Wybierz2==2)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[5].duchy<<endl;
                cout<<"|    2."<<Wybor[6].duchy<<endl;
                cout<<"|    3."<<Wybor[10].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[1].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"|    3."<<Wybor[5].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    Orb_EMF5_SpiritBox:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[5].duchy<<endl;
                    };
                    
                    Orb_EMF5_Writing:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[6].duchy<<endl;
                    };
                    
                    Orb_EMF5_Frezzing:
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[10].duchy<<endl;
                    };
            }
            
            Orb_FingerPrints:
            if(Wybierz2==3)
            {
                cout<<endl<<"Duch nazywa się: "<<Wybor[4].duchy<<endl;
            };
            
            Orb_Writing:
            
            if(Wybierz2==4)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[6].duchy<<endl;
                cout<<"|    2."<<Wybor[7].duchy<<endl<<endl;
                cout<<"| Wybierz opcję: "<<endl;
                cout<<"|    1."<<Wybor[4].opcje<<endl;
                cout<<"|    2."<<Wybor[5].opcje<<endl;
                cout<<"... ";
                cin>>Wybierz3;
                    Orb_Writing_Writing:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[6].duchy<<endl;
                    };
                
                    Orb_Writing_Frezzing:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[7].duchy<<endl;
                    };
            };
            
            Orb_Frezzing:
            if(Wybierz2==5)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[2].duchy<<endl;
                cout<<"|    2."<<Wybor[10].duchy<<endl;
                cout<<"|    3."<<Wybor[7].duchy<<endl<<endl;
                cout<<"| Wybierz opcję: "<<endl;
                cout<<"|    1."<<Wybor[1].opcje<<endl;
                cout<<"|    2."<<Wybor[2].opcje<<endl;
                cout<<"|    3."<<Wybor[4].opcje<<endl;
                cout<<"... ";
                cin>>Wybierz3;
                
                Orb_Frezzing_SpiritBox:
                if(Wybierz3==1)
                {
                    cout<<endl<<"Duch nazywa się: "<<Wybor[2].duchy<<endl;
                };
                
                Orb_Frezzing_Writing:
                if(Wybierz3==2)
                {
                    cout<<endl<<"Duch nazywa się: "<<Wybor[10].duchy<<endl;
                };
                
                Orb_Frezzing_EMF5:
                if(Wybierz3==3)
                {
                    cout<<endl<<"Duch nazywa się: "<<Wybor[7].duchy<<endl;
                };
            };
    };
    
    Spirit_Box:
    if(Wybierz==2)
    {
        cout<<endl<<"| Duchy:"<<endl;
        cout<<"|    1."<<Wybor[1].duchy<<endl;
        cout<<"|    2."<<Wybor[2].duchy<<endl;
        cout<<"|    3."<<Wybor[3].duchy<<endl;
        cout<<"|    4."<<Wybor[4].duchy<<endl;
        cout<<"|    5."<<Wybor[5].duchy<<endl;
        cout<<"|    6."<<Wybor[8].duchy<<endl;
        cout<<"|    7."<<Wybor[11].duchy<<endl<<endl;
            cout<<"| Wybierz opcję: "<<endl;
            cout<<"|    1."<<Wybor[0].opcje<<endl;
            cout<<"|    2."<<Wybor[2].opcje<<endl;
            cout<<"|    3."<<Wybor[3].opcje<<endl;
            cout<<"|    4."<<Wybor[4].opcje<<endl;
            cout<<"|    5."<<Wybor[5].opcje<<endl;
            cout<<"... ";
            cin>>Wybierz2;
            SpiritBox_Orb:
            if(Wybierz2==1)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[2].duchy<<endl;
                cout<<"|    2."<<Wybor[5].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[2].opcje<<endl;
                    cout<<"|    2."<<Wybor[5].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    SpiritBox_Orb_EMF5:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[2].duchy<<endl;
                    };
                    
                    SpiritBox_Orb_Frezzing:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[5].duchy<<endl<<endl;
                    };
            };
            SpiritBox_EMF5:
            if(Wybierz2==2)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[5].duchy<<endl;
                cout<<"|    2."<<Wybor[8].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[0].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    SpiritBox_EMF5_Orb:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[5].duchy<<endl<<endl;
                    };
                    
                    SpiritBox_EMF5_Writing:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[8].duchy<<endl<<endl;
                    };
                    
            };
            SpiritBox_FingerPrints:
            if(Wybierz2==3)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[3].duchy<<endl;
                cout<<"|    2."<<Wybor[4].duchy<<endl;
                cout<<"|    3."<<Wybor[11].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[4].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"|    3."<<Wybor[1].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    SpiritBox_FingerPrints_Writing:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[3].duchy<<endl<<endl;
                    };
                    
                    SpiritBox_FingerPrints_Orb:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[4].duchy<<endl<<endl;
                    }; 
                    
                    SpiritBox_FingerPrints_SpiritBox:
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[11].duchy<<endl<<endl;
                    };
            };
            SpiritBox_Writing:
            if(Wybierz2==4)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[1].duchy<<endl;
                cout<<"|    2."<<Wybor[3].duchy<<endl;
                cout<<"|    3."<<Wybor[8].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[5].opcje<<endl;
                    cout<<"|    2."<<Wybor[3].opcje<<endl;
                    cout<<"|    3."<<Wybor[2].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    SpiritBox_Writing_Frezzing:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[1].duchy<<endl<<endl;
                    };
                    
                    SpiritBox_Writing_FingerPrints:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[3].duchy<<endl<<endl;
                    }; 
                    
                    SpiritBox_Writing_EMF5:
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[8].duchy<<endl<<endl;
                    };
            };
            SpiritBox_Frezzing:
            if(Wybierz2==5)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[1].duchy<<endl;
                cout<<"|    2."<<Wybor[2].duchy<<endl;
                cout<<"|    3."<<Wybor[11].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[4].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"|    3."<<Wybor[3].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    SpiritBox_Frezzing_Writing:
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[1].duchy<<endl<<endl;
                    };
                    
                    SpiritBox_Frezzing_Orb:
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[2].duchy<<endl<<endl;
                    }; 
                    
                    SpiritBox_Frezzing_FingerPrints:
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[11].duchy<<endl<<endl;
                    };
            };
    }
    
    EMF5:
    if(Wybierz==3)
    {
        cout<<endl<<"| Duchy:"<<endl;
        cout<<"|    1."<<Wybor[0].duchy<<endl;
        cout<<"|    2."<<Wybor[5].duchy<<endl;
        cout<<"|    3."<<Wybor[6].duchy<<endl;
        cout<<"|    4."<<Wybor[8].duchy<<endl;
        cout<<"|    5."<<Wybor[9].duchy<<endl;
        cout<<"|    6."<<Wybor[10].duchy<<endl<<endl;
            cout<<"| Wybierz opcję: "<<endl;
            cout<<"|    1."<<Wybor[0].opcje<<endl;
            cout<<"|    2."<<Wybor[1].opcje<<endl;
            cout<<"|    3."<<Wybor[3].opcje<<endl;
            cout<<"|    4."<<Wybor[4].opcje<<endl;
            cout<<"|    5."<<Wybor[5].opcje<<endl;
            cout<<"... ";
            cin>>Wybierz2;
            
            EMF5_Orb:
            if(Wybierz2==1)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[5].duchy<<endl;
                cout<<"|    2."<<Wybor[6].duchy<<endl;
                cout<<"|    3."<<Wybor[10].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[1].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"|    3."<<Wybor[5].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[5].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[6].duchy<<endl<<endl;
                    }; 
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[10].duchy<<endl<<endl;
                    };
            };
            EMF5_SpiritBox:
            if(Wybierz2==2)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[5].duchy<<endl;
                cout<<"|    2."<<Wybor[8].duchy<<endl;
                    cout<<endl<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[0].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[5].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[8].duchy<<endl<<endl;
                    }; 
            };
            EMF5_FingerPrints:
            if(Wybierz2==3)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[0].duchy<<endl;
                cout<<"|    2."<<Wybor[9].duchy<<endl;
                    cout<<endl<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[5].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[0].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[9].duchy<<endl<<endl;
                    };
            };
            EMF5_Writing:
            if(Wybierz2==4)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[8].duchy<<endl;
                cout<<"|    2."<<Wybor[9].duchy<<endl;
                cout<<"|    3."<<Wybor[6].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[1].opcje<<endl;
                    cout<<"|    2."<<Wybor[3].opcje<<endl;
                    cout<<"|    3."<<Wybor[0].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[8].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[9].duchy<<endl<<endl;
                    }; 
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[6].duchy<<endl<<endl;
                    };
            };
            EMF5_Frezzing:
            if(Wybierz2==5)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[0].duchy<<endl;
                cout<<"|    2."<<Wybor[10].duchy<<endl;
                    cout<<endl<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[3].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[0].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[10].duchy<<endl<<endl;
                    };
            };
    };
    
    Finger_Prints:
    if(Wybierz==4)
    {
        cout<<endl<<"| Duchy:"<<endl;
        cout<<"|    1."<<Wybor[0].duchy<<endl;
        cout<<"|    2."<<Wybor[3].duchy<<endl;
        cout<<"|    3."<<Wybor[4].duchy<<endl;
        cout<<"|    4."<<Wybor[9].duchy<<endl;
        cout<<"|    5."<<Wybor[11].duchy<<endl<<endl;
            cout<<"| Wybierz opcję: "<<endl;
            cout<<"|    1."<<Wybor[0].opcje<<endl;
            cout<<"|    2."<<Wybor[1].opcje<<endl;
            cout<<"|    3."<<Wybor[2].opcje<<endl;
            cout<<"|    4."<<Wybor[4].opcje<<endl;
            cout<<"|    5."<<Wybor[5].opcje<<endl;
            cout<<"... ";
            cin>>Wybierz2;
            
            FingerPrints_Orb:
            if(Wybierz2==1)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[4].duchy<<endl;
                cout<<endl<<"Duch nazywa się: "<<Wybor[4].duchy<<endl<<endl;
            };
            FingerPrints_SpiritBox:
            if(Wybierz2==2)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[3].duchy<<endl;
                cout<<"|    2."<<Wybor[4].duchy<<endl;
                cout<<"|    3."<<Wybor[11].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[4].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"|    3."<<Wybor[5].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[3].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[4].duchy<<endl<<endl;
                    };
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[11].duchy<<endl<<endl;
                    };
            };
            FingerPrints_EMF5:
            if(Wybierz2==3)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[0].duchy<<endl;
                cout<<"|    2."<<Wybor[9].duchy<<endl;
                    cout<<endl<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[5].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[0].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[9].duchy<<endl<<endl;
                    };
            };
            FingerPrints_Writing:
            if(Wybierz2==4)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[3].duchy<<endl;
                cout<<"|    2."<<Wybor[9].duchy<<endl;
                    cout<<endl<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[3].opcje<<endl;
                    cout<<"|    2."<<Wybor[2].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[3].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[9].duchy<<endl<<endl;
                    };
            };
            FingerPrints_Frezzing:
            if(Wybierz2==5)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[0].duchy<<endl;
                cout<<"|    2."<<Wybor[11].duchy<<endl;
                    cout<<endl<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[2].opcje<<endl;
                    cout<<"|    2."<<Wybor[1].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[0].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[11].duchy<<endl<<endl;
                    };
            };
    };
    Writing:
    if(Wybierz==5)
    {
        cout<<endl<<"| Duchy:"<<endl;
        cout<<"|    1."<<Wybor[1].duchy<<endl;
        cout<<"|    2."<<Wybor[3].duchy<<endl;
        cout<<"|    3."<<Wybor[6].duchy<<endl;
        cout<<"|    4."<<Wybor[7].duchy<<endl;
        cout<<"|    5."<<Wybor[8].duchy<<endl;
        cout<<"|    6."<<Wybor[9].duchy<<endl<<endl;
            cout<<"| Wybierz opcję: "<<endl;
            cout<<"|    1."<<Wybor[0].opcje<<endl;
            cout<<"|    2."<<Wybor[1].opcje<<endl;
            cout<<"|    3."<<Wybor[2].opcje<<endl;
            cout<<"|    4."<<Wybor[3].opcje<<endl;
            cout<<"|    5."<<Wybor[5].opcje<<endl;
            cout<<"... ";
            cin>>Wybierz2;
            Writing_Orb:
            if(Wybierz2==1)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[6].duchy<<endl;
                cout<<"|    2."<<Wybor[7].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[2].opcje<<endl;
                    cout<<"|    2."<<Wybor[5].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[6].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[7].duchy<<endl<<endl;
                    };
            };
            Writing_SpiritBox:
            if(Wybierz2==2)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[1].duchy<<endl;
                cout<<"|    2."<<Wybor[3].duchy<<endl;
                cout<<"|    3."<<Wybor[8].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[5].opcje<<endl;
                    cout<<"|    2."<<Wybor[3].opcje<<endl;
                    cout<<"|    3."<<Wybor[2].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[1].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[3].duchy<<endl<<endl;
                    };
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[8].duchy<<endl<<endl;
                    };
            };
            Writing_EMF5:
            if(Wybierz2==3)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[6].duchy<<endl;
                cout<<"|    2."<<Wybor[8].duchy<<endl;
                cout<<"|    3."<<Wybor[9].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[0].opcje<<endl;
                    cout<<"|    2."<<Wybor[1].opcje<<endl;
                    cout<<"|    3."<<Wybor[3].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[6].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[8].duchy<<endl<<endl;
                    };
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[9].duchy<<endl<<endl;
                    };
            };
            Writing_FingerPrints:
            if(Wybierz2==4)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[3].duchy<<endl;
                cout<<"|    2."<<Wybor[9].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[2].opcje<<endl;
                    cout<<"|    2."<<Wybor[1].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[3].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[9].duchy<<endl<<endl;
                    };
            };
            Writing_Frezzing:
            if(Wybierz2==5)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[1].duchy<<endl;
                cout<<"|    2."<<Wybor[7].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[1].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[1].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[7].duchy<<endl<<endl;
                    };
            };
    };
    Frezzing:
    if(Wybierz==6)
    {
        cout<<endl<<"| Duchy:"<<endl;
        cout<<"|    1."<<Wybor[0].duchy<<endl;
        cout<<"|    2."<<Wybor[1].duchy<<endl;
        cout<<"|    3."<<Wybor[2].duchy<<endl;
        cout<<"|    4."<<Wybor[7].duchy<<endl;
        cout<<"|    5."<<Wybor[10].duchy<<endl;
        cout<<"|    6."<<Wybor[11].duchy<<endl<<endl;
            cout<<"| Wybierz opcję: "<<endl;
            cout<<"|    1."<<Wybor[0].opcje<<endl;
            cout<<"|    2."<<Wybor[1].opcje<<endl;
            cout<<"|    3."<<Wybor[2].opcje<<endl;
            cout<<"|    4."<<Wybor[3].opcje<<endl;
            cout<<"|    5."<<Wybor[4].opcje<<endl;
            cout<<"... ";
            cin>>Wybierz2;
            Frezzing_Orb:
            if(Wybierz2==1)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[2].duchy<<endl;
                cout<<"|    2."<<Wybor[7].duchy<<endl;
                cout<<"|    3."<<Wybor[10].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[1].opcje<<endl;
                    cout<<"|    2."<<Wybor[4].opcje<<endl;
                    cout<<"|    3."<<Wybor[2].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[2].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[7].duchy<<endl<<endl;
                    };
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[10].duchy<<endl<<endl;
                    };
            };
            Frezzing_SpiritBox:
            if(Wybierz2==2)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[1].duchy<<endl;
                cout<<"|    2."<<Wybor[2].duchy<<endl;
                cout<<"|    3."<<Wybor[11].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[4].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"|    3."<<Wybor[3].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[1].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[2].duchy<<endl<<endl;
                    };
                    if(Wybierz3==3)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[11].duchy<<endl<<endl;
                    };
            };
            Frezzing_EMF5:
            if(Wybierz2==3)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[0].duchy<<endl;
                cout<<"|    2."<<Wybor[10].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[3].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[0].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[10].duchy<<endl<<endl;
                    };
            };
            Frezzing_FingerPrints:
            if(Wybierz2==4)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[0].duchy<<endl;
                cout<<"|    2."<<Wybor[11].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[2].opcje<<endl;
                    cout<<"|    2."<<Wybor[1].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[0].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[11].duchy<<endl<<endl;
                    };
            };
            Frezzing_Writing:
            if(Wybierz2==5)
            {
                cout<<endl<<"| Duchy:"<<endl;
                cout<<"|    1."<<Wybor[1].duchy<<endl;
                cout<<"|    2."<<Wybor[7].duchy<<endl<<endl;
                    cout<<"| Wybierz opcję: "<<endl;
                    cout<<"|    1."<<Wybor[1].opcje<<endl;
                    cout<<"|    2."<<Wybor[0].opcje<<endl;
                    cout<<"... ";
                    cin>>Wybierz3;
                    if(Wybierz3==1)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[1].duchy<<endl<<endl;
                    };
                    if(Wybierz3==2)
                    {
                        cout<<endl<<"Duch nazywa się: "<<Wybor[7].duchy<<endl<<endl;
                    };
            };
    };
}

Miałem pare pomysłów z pętlą ale żadnego nie udało mi się wprowadzić póki co wszystko wygląda w ten sposób pisanie tego trochę mi zajęło proszę o pomoc.

2

No Bracie to jest ta pora kiedy przychodzi ci zapoznać się z std::unordered_map, chyba iż koniecznie to musi być w C (ale wówczas couta i cina nie wolno używać).

0

Przeanalizuj sobie poniższy przykład:

#include <iostream>
#include <list>
#include <algorithm>
#include <set>

using namespace std;

struct Ghost
{
    string name;
    list<string> traits;
};

int main()
{
    list<Ghost> ghosts {
                           {"Banshee",{"EMF_5","Temperature","Fingerprint"}},
                           {"Demon",{"Temperature","Walkie_Talkie","Book"}},
                           {"Mare",{"Temperature","Orb","Walkie_Talkie"}},
                           {"Spirit",{"Walkie_Talkie","Book","Fingerprint"}},
                           {"Poltergeist",{"Walkie_Talkie","Fingerprint","Orb"}},
                           {"Jinn",{"EMF_5","Orb","Walkie_Talkie"}},
                           {"Shade",{"EMF_5","Book","Orb"}},
                           {"Yurei",{"Temperature","Orb","Book"}},
                           {"Oni",{"EMF_5","Book","Walkie_Talkie"}},
                           {"Revenant",{"EMF_5","Book","Fingerprint"}},
                           {"Phantom",{"Temperature","Orb","EMF_5"}},
                           {"Wendiego",{"Temperature","Walkie_Talkie","Fingerprint"}}
                         };

    auto traits = [&](){
                         set<string> result;
                         for( const auto& ghost : ghosts ) for( const auto& trait : ghost.traits ) result.insert(trait);
                         return list<string>(begin(result),end(result));
                       }();

    while( size(ghosts) > 1 )
    {
        string choose_trait;
        while(true)
        {
            cout << endl;
            for( const auto trait : traits ) cout << trait << ' ';
            cout << endl << "Enter trait name:" << endl;
            cin >> choose_trait;

            auto trait = find(begin(traits), end(traits), choose_trait );
            if( trait != end(traits) )
            {
                traits.erase( find(begin(traits), end(traits), choose_trait ) );
                break;
            }
            else cout << "Invalid trait name " << endl;
        }

        for( auto ghost = begin(ghosts) ; ghost!= end(ghosts) ; )
        {
            auto finding_trait = find(cbegin(ghost->traits), cend(ghost->traits), choose_trait );
            if( finding_trait != cend(ghost->traits) ) ++ghost;
            else ghost = ghosts.erase(ghost);
        }

        if( size(ghosts) < 2 ) continue;
        cout << "Found following ghosts" << endl;
        for( const auto& ghost : ghosts ) cout << ghost.name << ' ';
        cout << endl;
    }

    if( size(ghosts) == 1 ) cout << endl << "Founding ghost is " << (*ghosts.begin()).name << endl;
    else cout << endl << "You fail to guess!" << endl;
}

https://godbolt.org/z/eqEEjoPGj

0

ogólnie chciałbym aby to było w c++ wszystko twój program @TomaszLiMoon nie działa w moim kompilatorze najlepiej by było gdybyś podał mi jakąś komende i prosto to napisał bo też nie za bardzo rozumiem jak to działa widzę że jest jakaś pętla ale bardziej mi chodzi o to żeby podpisać jakiegoś danego ducha kilkoma parametrami i na podstawie tych parametrów wyszukiwać ducha dlatego zrobiłem tam tyle opcji żeby dało się wyszukać każdego ducha z każdym parametrem jakiś filtr nie muszą to być pętle wyświetlanie to nie jest problem

5
    cout<<"|    1."<<Wybor[0].opcje<<endl;
    cout<<"|    2."<<Wybor[1].opcje<<endl;
    cout<<"|    3."<<Wybor[2].opcje<<endl;
    cout<<"|    4."<<Wybor[3].opcje<<endl;
    cout<<"|    5."<<Wybor[4].opcje<<endl;
    cout<<"|    6."<<Wybor[5].opcje<<endl;

słyszałeś o czym takim jak pętle! To jest takie coś co bardzo się lubi z tablicami, które już masz.

0

@MarekR22: nie rozumiesz o co mi chodzi każdy duch tam ma swoje 3 opcje wyboru nie chodzi mi o to żeby tam wstawiać w pętle bo co z tego jak dam pętle skoro każdy ma inny wybór a nie chodzi mi o to żeby to się powtarzało chyba że ja po prostu źle myślę, ale ogólnie chodzi mi o to żeby pod każdego ducha podpisać 3 parametry które po wpisaniu wyświetlają po kolei np duch z jednym parametrem potem wpisuje drugi i trzeci i pula zmniejsza się do jednego ducha który ma unikatowe 3 parametry które nie powtarzają się...

Program już mam gotowy i osiągnąłem to co chciałem ale jeżeli da się to jakoś lepiej zapisać może wprowadzić jakąś funkcje której nie znam albo może pętlę tylko póki co nie wyobrażam sobie tego, albo inaczej nie wiem jak to zrobić.

Wiem że to jest źle napisane bo sam to pisałem i widzę ale nie wiem jak zastosować tam pętle jeśli się w ogóle da tam jest uwzględnione to co chciałem może spróbuje coś wykombinować z tymi pętlami jak mi się uda to dodam tutaj a jak nie to nie dodam nigdy

0

@TomaszLiMoon: dobra już wiem dlaczego program mi nie działał zaznaczyłem c++ a to jest c++ 17 teraz wszystko działa przeanalizuje sobie ten program i spróbuje na podstawie twojego stworzyć własny dzięki za pomoc i macie rację co do tych pętli po prostu ja mam za mało doświadczenia i nie wiedziałem że do pętli można dodawać tyle funkcji, jak na razie to spróbuje coś ogarnąć w tym zakresie i zrozumieć też parę funkcji bo to co tutaj widzę to jest dla mnie póki co skomplikowane może mi to trochę zająć więc jak skończę to wyślę tutaj rezultaty mojej pracy. Dziękuję za pomoc

1 użytkowników online, w tym zalogowanych: 0, gości: 1