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
|
#include<iostream>
#include<cstdlib>
using namespace std;
char p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,p31,p32,p33,p34,p35;
char value_checker(char o, char p , char i , int w, int x){
if(i==o && w==x){
if(p=='X'){
p='O';
}
else{
p='X';
}
}
return p;
}
char value_assigner(){
char pos;
char g;
int e;
e=rand() % 300+1 ;
if(e%2==0){
g='O';
}
else if (e%2!=0){
g='X';
}
pos = g;
return g;
}
bool parity_checker(char x0,char x1,char x2,char x3,char x4,char x5){
int counter=0;
if(x0=='X'){
counter=counter+1;
}
if(x1=='X'){
counter=counter+1;
}
if(x2=='X'){
counter=counter+1;
}
if(x3=='X'){
counter=counter+1;
}
if(x4=='X'){
counter=counter+1;
}
if(x5=='X'){
counter=counter+1;
}
if(counter%2!=0){
return true;
}
else{
return false;
}
}
int main(){
char char_input;
srand(time(0));
bool b=true;
do{
while(b){
p0 =value_assigner();
p1 =value_assigner();
p2 =value_assigner();
p3 =value_assigner();
p4 =value_assigner();
p5 =value_assigner();
p6 =value_assigner();
p7 =value_assigner();
p8 =value_assigner();
p9 =value_assigner();
p10 =value_assigner();
p11 =value_assigner();
p12=value_assigner();
p13=value_assigner();
p14=value_assigner();
p15=value_assigner();
p16=value_assigner();
p17=value_assigner();
p18=value_assigner();
p19=value_assigner();
p20=value_assigner();
p21=value_assigner();
p22=value_assigner();
p23=value_assigner();
p24=value_assigner();
p25=value_assigner();
p26 =value_assigner();
p27=value_assigner();
p28=value_assigner();
p29=value_assigner();
p30=value_assigner();
p31=value_assigner();
p32=value_assigner();
p33=value_assigner();
p34=value_assigner();
p35=value_assigner();
if((parity_checker(p0,p6,p12,p18,p24,p30) && parity_checker(p0,p1,p2,p3,p4,p5)
&& parity_checker(p6,p7,p8,p9,p10,p11) && parity_checker(p12,p13,p14,p15,p16,p17)
&& parity_checker(p18,p19,p20,p21,p22,p23) && parity_checker(p24,p25,p26,p27,p28,p29)
&& parity_checker(p30,p31,p32,p33,p34,p35) && parity_checker(p1,p7,p13,p19,p25,p31)
&& parity_checker(p2,p8,p14,p20,p26,p32) && parity_checker(p3,p9,p15,p21,p27,p33)
&& parity_checker(p4,p10,p16,p22,p28,p34) && parity_checker(p5,p11,p17,p23,p29,p35))==true){
b=false;
}
}
cout<< " 1 2 3 4 5 6"<<endl;
cout<< " ------------"<<endl;
cout<<"A |"<<p0<<" "<< p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "<<p5<<" | "<<"A"<<endl;
cout<<"B |"<<p6<<" "<< p7<<" "<<p8<<" "<<p9<<" "<<p10<<" "<<p11<<" | "<<"B"<<endl;
cout<<"C |"<<p12<<" "<< p13<<" "<<p14<<" "<<p15<<" "<<p16<<" "<<p17<<" | "<<"C"<<endl;
cout<<"D |"<<p18<<" "<< p19<<" "<<p20<<" "<<p21<<" "<<p22<<" "<<p23<<" | "<<"D"<<endl;
cout<<"E |"<<p24<<" "<< p25<<" "<<p26<<" "<<p27<<" "<<p28<<" "<<p29<<" | "<<"E"<<endl;
cout<<"F |"<<p30<<" "<< p31<<" "<<p32<<" "<<p33<<" "<<p34<<" "<<p35<<" | "<<"F"<<endl;
cout<<"Enter 'r' to randomize or position to flip"<<endl;
cin>>char_input;
}while(char_input=='r');
return 0;
}
|