Ich kann das Problem bisher nur so lösen:
C
- #include <iostream>
- #include <time.h>
- using namespace std;
- int main()
- {
- srand(static_cast<unsigned>(time(0)));
- int random_integer;
- for(int index = 0; index < 10; index++)
- {
- random_integer = (rand()%10)+1;
- }
- // Per static_cast die Buchstaben in ihren ASCII-Deizmalwert umwandeln
- int card[] = {2, 3, 4, 5, 6, 7, 8, 9, static_cast<int>('B'), static_cast<int>('Q'), static_cast<int>('K'), static_cast<int>('A')};
- // Per switch rausfinden ob der Index einen Buchstaben (deren ASCII-Dezimalwert)
- // beinhaltet und per static_cast in character umwandeln
- // ansonsten normale Ausgabe
- switch (card[random_integer])
- {
- case (static_cast<int>('B')):
- {
- cout << static_cast<char>(card[random_integer]) << endl;
- } break;
- case (static_cast<int>('Q')):
- {
- cout << static_cast<char>(card[random_integer]) << endl;
- } break;
- case (static_cast<int>('K')):
- {
- cout << static_cast<char>(card[random_integer]) << endl;
- } break;
- case (static_cast<int>('A')):
- {
- cout << static_cast<char>(card[random_integer]) << endl;
- }
- default:
- cout << card[random_integer] << endl;
- }
- system ("Pause");
- }