1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int BootVier, BootDrie, BootTwee, BootEen;
int BootTotaal = BootVier + BootDrie + BootTwee + BootEen;
char input;
char array[10][10] =
{
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'},
{'-', '-', '-', '-', '-', '-', '-', '-', '-', '-'}
};
char array2[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
int array3[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int ran1;
int ran2;
void Speelbord ()
{
cout<<" 0 1 2 3 4 5 6 7 8 9\n";
cout<<"A "<<array[0][0]<<" "<<array[0][1]<<" "<<array[0][2]<<" "<<array[0][3]<<" "<<array[0][4]<<" "<<array[0][5]<<" "<<array[0][6]<<" "<<array[0][7]<<" "<<array[0][8]<<" "<<array[0][9]<<"\n";
cout<<"B "<<array[1][0]<<" "<<array[1][1]<<" "<<array[1][2]<<" "<<array[1][3]<<" "<<array[1][4]<<" "<<array[1][5]<<" "<<array[1][6]<<" "<<array[1][7]<<" "<<array[1][8]<<" "<<array[1][9]<<"\n";
cout<<"C "<<array[2][0]<<" "<<array[2][1]<<" "<<array[2][2]<<" "<<array[2][3]<<" "<<array[2][4]<<" "<<array[2][5]<<" "<<array[2][6]<<" "<<array[2][7]<<" "<<array[2][8]<<" "<<array[2][9]<<"\n";
cout<<"D "<<array[3][0]<<" "<<array[3][1]<<" "<<array[3][2]<<" "<<array[3][3]<<" "<<array[3][4]<<" "<<array[3][5]<<" "<<array[3][6]<<" "<<array[3][7]<<" "<<array[3][8]<<" "<<array[3][9]<<"\n";
cout<<"E "<<array[4][0]<<" "<<array[4][1]<<" "<<array[4][2]<<" "<<array[4][3]<<" "<<array[4][4]<<" "<<array[4][5]<<" "<<array[4][6]<<" "<<array[4][7]<<" "<<array[4][8]<<" "<<array[4][9]<<"\n";
cout<<"F "<<array[5][0]<<" "<<array[5][1]<<" "<<array[5][2]<<" "<<array[5][3]<<" "<<array[5][4]<<" "<<array[5][5]<<" "<<array[5][6]<<" "<<array[5][7]<<" "<<array[5][8]<<" "<<array[5][9]<<"\n";
cout<<"G "<<array[6][0]<<" "<<array[6][1]<<" "<<array[6][2]<<" "<<array[6][3]<<" "<<array[6][4]<<" "<<array[6][5]<<" "<<array[6][6]<<" "<<array[6][7]<<" "<<array[6][8]<<" "<<array[6][9]<<"\n";
cout<<"H "<<array[7][0]<<" "<<array[7][1]<<" "<<array[7][2]<<" "<<array[7][3]<<" "<<array[7][4]<<" "<<array[7][5]<<" "<<array[7][6]<<" "<<array[7][7]<<" "<<array[7][8]<<" "<<array[7][9]<<"\n";
cout<<"I "<<array[8][0]<<" "<<array[8][1]<<" "<<array[8][2]<<" "<<array[8][3]<<" "<<array[8][4]<<" "<<array[8][5]<<" "<<array[8][6]<<" "<<array[8][7]<<" "<<array[8][8]<<" "<<array[8][9]<<"\n";
cout<<"J "<<array[9][0]<<" "<<array[9][1]<<" "<<array[9][2]<<" "<<array[9][3]<<" "<<array[9][4]<<" "<<array[9][5]<<" "<<array[9][6]<<" "<<array[9][7]<<" "<<array[9][8]<<" "<<array[9][9]<<"\n";
}
char inputGen()
{
cin>> input;
if (input == 'o' || input == 'x')
{
array[ran1][ran2] = input;
}
else
{
cout<<"Sorry, dat is geen correcte input, probeer het opnieuw:";
inputGen();
}
}
char random ()
{
for(int i = 0; i < 100; i++)
{
srand ( (unsigned)time(NULL) );
ran1 = rand()%10;
ran2 = rand()%10;
if (array[ran1][ran2] == '-')
{
cout<<array2[ran1]<<array3[ran2]<<":\n";
inputGen();
}
else
{
random();
}
Speelbord();
}
};
char inputBeginC2()
{
cout<<"c2:\n";
cin>> input;
if (input == 'o' || input == 'x')
{
array[2][2] = input;
}
else
{
cout<<"Sorry, dat is geen correcte input, probeer het opnieuw";
inputBeginC2();
}
}
char inputBeginC7()
{
cout<<"c7:\n";
cin>> input;
if (input == 'o' || input == 'x')
{
array[2][7] = input;
}
else
{
cout<<"Sorry, dat is geen correcte input, probeer het opnieuw";
inputBeginC7();
}
}
char inputBeginH2()
{
cout<<"h2:\n";
cin>> input;
if (input == 'o' || input == 'x')
{
array[7][2] = input;
}
else
{
cout<<"Sorry, dat is geen correcte input, probeer het opnieuw";
inputBeginH2();
}
}
char inputBeginH7()
{
cout<<"h7:\n";
cin>> input;
if (input == 'o' || input == 'x')
{
array[7][7] = input;
}
else
{
cout<<"Sorry, dat is geen correcte input, probeer het opnieuw";
inputBeginH7();
}
}
void begin ()
{
Speelbord ();
inputBeginC2();
Speelbord ();
inputBeginC7();
Speelbord ();
inputBeginH2();
Speelbord ();
inputBeginH7();
Speelbord ();
}
int main()
{
begin();
random();
Speelbord();
cin.ignore();
cin.get();
}
|