Zmiana Wartości danych z tablicy

0

Witam. Mam następujący problem a mianowicie co mam zrobić żeby przy wylosowaniu liczby przy indeksie t[36],t[37],t[38],t[39] program wypisał: wylosowana karta to walet.

 #include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <ctime>
#include <stdio.h>
using namespace std;
int main()
{
    int i = 0;
 
 
    int wybor;
    cout << "witaj w grze Oczko " << endl;

    srand( time( NULL ) );
 
    int t[ 52 ];
 
    t[ 0 ] = 2; t[ 1 ] = 2; t[ 2 ] = 2; t[ 3 ] = 2; t[ 4 ] = 3; t[ 5 ] = 3; t[ 6 ] = 3; t[ 7 ] = 3; t[ 8 ] = 4; t[ 9 ] = 4; t[ 10 ] = 4;
    t[ 11 ] = 4; t[ 12 ] = 5; t[ 13 ] = 5; t[ 14 ] = 5; t[ 15 ] = 5; t[ 16 ] = 6; t[ 17 ] = 6; t[ 18 ] = 6; t[ 19 ] = 6; t[ 20 ] = 7;
    t[ 21 ] = 7; t[ 22 ] = 7; t[ 23 ] = 7; t[ 24 ] = 8; t[ 25 ] = 8; t[ 26 ] = 8; t[ 27 ] = 8; t[ 28 ] = 9; t[ 29 ] = 9; t[ 30 ] = 9;
    t[ 31 ] = 9; t[ 32 ] = 10; t[ 33 ] = 10 ; t[ 34 ] = 10; t[ 35 ] = 10; t[ 36 ] =  2; t[ 37 ] = 2; t[ 38 ] =  2; t[ 39 ] =  2; t[ 40 ] = 3;
    t[ 41 ] = 3; t[ 42 ] = 3; t[ 43 ] = 3; t[ 44 ] = 4; t[ 45 ] = 04; t[ 46 ] = 4; t[ 47 ] = 4; t[ 48 ] = 11; t[ 49 ] = 11; t[ 50 ] = 11;
    t[ 51 ] = 11;
    for( int y = 0; y < 2; y++ )
 
    {
 
    t[ y ] = t[ rand() % 52 ];
        cout << "Wartosc  wylosowanej karty to :" << t[ y ] << endl;
        cout << "*********************************" << endl;
    }
 
 
    for( int j = 0; j < 2; j++ )
    {
        i = i + t[ j ];
    }
    cout << "Suma wartosci kart wynosi: " << i << endl;
 
 
    if( i == 21 )
    {
        cout << "BLACK JACK" << endl;
        return 0;
    }
    if( i > 21 )
    {
        cout << "wartosc obu kart przekracza 21" << endl;
        return 0;
    }
 
 
    cout << "[1] dobierz karte [2] pozostan przy wylosowanych kartach" << endl;
    cin >> wybor;
 
    if( wybor == 1 )
    do
    {
 
        for( int y = 0; y < 1; y++ )
 
        {
 
            t[ y ] = t[ rand() % 52 ];
            cout << "Wartosc  wylosowanej karty to :" << t[ y ] << endl;
        }
        for( int j = 0; j < 1; j++ )
        {
            i = i + t[ j ];
        }
        cout << "Suma wartosci kart wynosi: " << i << endl;
        if( i == 21 )
        {
            cout << "BLACK JACK" << endl;
            return 0;
        }
        if( i > 21 )
        {
            cout << "wartosc obu kart przekracza 21 " << endl;
 
            return 0;
        }
        cout << "[1] dobierz karte [2] pozostan przy wylosowanych kartach" << endl;
        cin >> wybor;
    }
    while( wybor == 1 );
 
    cout << "twoj ostateczny wynik to" << i << endl;
    return 0;
 
}
0
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;

const unsigned suitCount=4;
const unsigned cardCount=13;
const unsigned taleCount=suitCount*cardCount;
const char *Suit[]={"\x3","\x4","\x5","\x6"};
const char *Cards[]={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
const unsigned Values[]={2,3,4,5,6,7,8,9,10,10,10,10,11};

int main()
  {
   unsigned tale[taleCount];
   for(unsigned i=0;i<taleCount;++i) tale[i]=i;
   srand(time(0));
   for(unsigned p=taleCount-1;p<taleCount;--p)
     {
      if(p) swap(tale[p],tale[rand()%(p+1)]);
      cout<<Cards[tale[p]>>2]<<Suit[tale[p]&3]<<" wartosc "<<Values[tale[p]>>2]<<" :";
      cin.get();
     }
   return 0;
  }

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