Wątek przeniesiony 2018-08-10 16:14 z C/C++ przez furious programming.

Tablica dwuwymiarowa – aktualizowanie zawartości

0

Witam,
Mam problem z utworzeniem automatycznej tablicy która ma działać tak że po kliknieciu 1 lub 2 podana na początku kodu tabela doda +1 do wygranych danej drużyny lub doda 1+ do przegranych danej drużyny. Problemem jest to że nie wiem do końca jak to wykonać i jakich funkcji użyć. Tablice wykonuje w C++ oto kod, co zrobić by po wybraniu wygranej drużyny automatycznie dodać +1 do wygranych.

#include <iostream>
using namespace std;

int main()
{

    int tab[10][4];

    tab[0][0] = 1;
    tab[0][1];
    tab[0][2] = 10;
    tab[0][3] = 4;

    tab[1][0] = 2 ;
    tab[1][1];
    tab[1][2] = 10 ;
    tab[1][3] = 4 ;

    tab[2][0] = 3;
    tab[2][1];
    tab[2][2] = 9;
    tab[2][3] = 5;

    tab[3][0] = 4;
    tab[3][1];
    tab[3][2]=9;
    tab[3][3]=5;

    tab[4][0] = 5;
    tab[4][1];
    tab[4][2]=9;
    tab[4][3]=5;

    tab[5][0] = 6;
    tab[5][1];
    tab[5][2]=7;
    tab[5][3]=7;

    tab[6][0] = 7;
    tab[6][1];
    tab[6][2]=6;
    tab[6][3]=8;

    tab[7][0]=8;
    tab[7][1];
    tab[7][2]=5;
    tab[7][3]=9;

    tab[8][0]=9;
    tab[8][1];
    tab[8][2]=4;
    tab[8][3]=10;

    tab[9][0]=10;
    tab[9][1];
    tab[9][2]=1;
    tab[9][3]=13;

    cout << tab[0][0];
    int *Fnatic = &tab[0][1];
    cout << "  fnatic ";
    cout <<"    "<< tab[0][2]<<" : ";
    cout << tab[0][3]<<endl;

    cout << tab[1][0] ;
    int *Misfits = &tab[1][1];
    cout << "  misfits";
    cout <<"    "<< tab[1][2]<<" : ";
    cout << tab[1][3]<<endl;

    cout << tab[2][0];
    int *S04 = &tab[2][1];
    cout << "  S04 ";
    cout <<"        "<< tab[2][2]<<" : ";
    cout << tab[2][3]<<endl;


    cout<<tab[3][0];
    int *Vitality = &tab[3][1];
    cout << "  Vitality ";
    cout <<"   "<< tab[3][2]<<" : ";
    cout << tab[3][3]<<endl;

    cout<<tab[4][0];
    int *G2 = &tab[4][1];
    cout << "  G2 Esport ";
    cout <<"  "<< tab[4][2]<<" : ";
    cout << tab[4][3]<<endl;

    cout<<tab[5][0];
    int *SPlyce = &tab[5][1];
    cout << "  Splyce";
    cout<<"      "<<tab[5][2]<< " : ";
    cout << tab[5][3]<<endl;

    cout<<tab[6][0];
    int *Roccat = &tab[6][1];
    cout << "  Roccat";
    cout <<"      "<< tab[6][2]<<" : ";
    cout << tab[6][3]<<endl;

    cout<<tab[7][0];
    int *GIANTS = &tab[7][1];
    cout << "  Giants";
    cout <<"      "<< tab[7][2]<<" : ";
    cout << tab[7][3]<<endl;

    cout<<tab[8][0];
    int *UOL= &tab[8][1];
    cout << "  Unicorns";
    cout <<"    "<< tab[8][2]<<" : ";
    cout << tab[8][3]<<endl;

    cout<<tab[9][0];
    int *h2k = &tab[9][1];
    cout << " H2k   ";
    cout <<"      "<< tab[9][2]<<" : ";
    cout << tab[9][3]<<endl;

    int wybor1;
    int i;
    cout<<endl;
    cout<<"wybierz 1 lub 2"<<endl;
    cout<<"Roccat vs Splyce"<<endl;
    cin>>wybor1;

switch(wybor1){

            case 1: cout<<"Roccat";
    break;
    case 2: cout<< " Splyce";
break;

    }
int wybor2;
cout<<endl;
cout<<"H2k vs Misfits"<<endl;
cin>>wybor2;
switch(wybor2){
case 1: cout<<"H2k"<<endl;
break;
case 2: cout<<"Misfits"<<endl;
break;
}

int wybor3;
cout<<endl;
cout<<"Uol vs G2"<<endl;
cin>>wybor3;
switch(wybor3){
case 1: cout<<"UOL"<<endl;
break;
case 2: cout<<"G2"<<endl;
break;
}

int wybor4;
cout<<endl;
cout<<"Fnatic vs Giants"<<endl;
cin>>wybor4;
switch(wybor2){
case 1: cout<<"Fnatic"<<endl;
break;
case 2: cout<<"Giants"<<endl;
break;
}

int wybor5;
cout<<endl;
cout<<"S04 vs Vitality"<<endl;
cin>>wybor5;
switch(wybor5){
case 1: cout<<"S04"<<endl;
break;
case 2: cout<<"Vitality"<<endl;
break;
}
    return 0;
}
2

zmiłuj się i nie twórz takich enigmatycznych tablic i nie dźgaj wszystkiego w main (definiuj małe funkcje).

zdefiniuj strukturę z potrzebnymi danymi:

struct Team
{
    std::string name;
    int winCount;
    int drawCount;
    int lostCount;
};

Napisz wszystko od nowa z tmi wskazówkami, a pewnie samo ci wyjdzie.

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