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
|
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
using namespace std;
float n1,n2,n3,n4,n5,n6,n7,n8,n9,n10;
void enter10numbers(),errorscreen();
void finalerrorscreen();
void pointcalculation();
void calc1(),calc2(),calc3(),calc4(),calc5(),calc6(),calc7(),calc8(),calc9(),calc10();
int choice;
int userspointtotal;
float p1=1;
float t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
int cg1,cg2,cg3,cg4,cg5,cg6,cg7,cg8,cg9,cg10;
int main()
{
string name;
srand(time(0));
cg1= rand()%2+1;
cg2=rand()%2+1;
cg3=rand()%2+1;
cg4=rand()%2+1;
cg5=rand()%2+1;
cg6=rand()%2+1;
cg7=rand()%2+1;
cg8=rand()%2+1;
cg9=rand()%2+1;
cg10=rand()%2+1;
cout<<"Please enter your name:"<<endl;
cin>>name;
cout<<name<<" the computer has picked 10 numbers between 1-50."<<endl;
cout<<"You will choose 10 numbers 1-50, trying to guess what the computer has chosen."<<endl;
cout<<"(You will be given a point for each number chosen correctly)"<<endl;
enter10numbers();
return 0;
}
void enter10numbers()
{
cout<<"Please start entering now (note numbers must be between 1-50)(Enter 0 to quit): "<<endl;
cin>>n1;
if(n1>50||n1<1)
errorscreen();
cin>>n2;
if(n2>50||n2<1)
errorscreen();
cin>>n3;
if(n3>50||n3<1)
errorscreen();
cin>>n4;
if(n4>50||n4<1)
errorscreen();
cin>>n5;
if(n5>50||n5<1)
errorscreen();
cin>>n6;
if(n6>50||n6<1)
errorscreen();
cin>>n7;
if(n7>50||n7<1)
errorscreen();
cin>>n8;
if(n8>50||n8<1)
errorscreen();
cin>>n9;
if(n9>50||n9<1)
errorscreen();
cin>>n10;
if(n10>50||n10<1)
errorscreen();
calc1();
}
void errorscreen()
{
cout<<"Are you sure you would like to exit the program? 1 for Yes 0 for No:"<<endl;
cin>>choice;
if (choice==1)
exit(0);
else
finalerrorscreen();
}
void finalerrorscreen()
{
cout<<"Error"<<endl;
cout<<"One or more numbers you have entered are to large to great."<<endl;
enter10numbers();
}
void calc1()
{
if(n1==cg1||n1==cg2||n1==cg3||n1==cg4||n1==cg5||n1==cg6||n1==cg7||n1==cg8||n1==cg9||n1==cg10)
t1=0+p1;
calc2();
}
void calc2()
{
if(n2==cg1||n2==cg2||n2==cg3||n2==cg4||n2==cg5||n2==cg6||n2==cg7||n2==cg8||n2==cg9||n2==cg10)
t2=0+p1;
calc3();
}
void calc3()
{
if(n3==cg1||n3==cg2||n3==cg3||n3==cg4||n3==cg5||n3==cg6||n3==cg7||n3==cg8||n3==cg9||n3==cg10)
t3=0+p1;
calc4();
}
void calc4()
{
if(n4==cg1||n4==cg2||n4==cg3||n4==cg4||n4==cg5||n4==cg6||n4==cg7||n4==cg8||n4==cg9||n4==cg10)
t4=0+p1;
calc5();
}
void calc5()
{
if(n5==cg1||n5==cg2||n5==cg3||n5==cg4||n5==cg5||n5==cg6||n5==cg7||n5==cg8||n5==cg9||n5==cg10)
t5=0+p1;
calc6();
}
void calc6()
{
if(n6==cg1||n6==cg2||n6==cg3||n6==cg4||n6==cg5||n6==cg6||n6==cg7||n6==cg8||n6==cg9||n6==cg10)
t6=0+p1;
calc7();
}
void calc7()
{
if(n7==cg1||n7==cg2||n7==cg3||n7==cg4||n7==cg5||n7==cg6||n7==cg7||n7==cg8||n7==cg9||n7==cg10)
t7=0+p1;
calc8();
}
void calc8()
{
if(n8==cg1||n8==cg2||n8==cg3||n8==cg4||n8==cg5||n8==cg6||n8==cg7||n8==cg8||n8==cg9||n8==cg10)
t8=0+p1;
calc9();
}
void calc9()
{
if(n9==cg1||n9==cg2||n9==cg3||n9==cg4||n9==cg5||n9==cg6||n9==cg7||n9==cg8||n9==cg9||n9==cg10)
t9=0+p1;
calc10();
}
void calc10()
{
if(n10==cg1||n10==cg2||n10==cg3||n10==cg4||n10==cg5||n10==cg6||n10==cg7||n10==cg8||n10==cg9||n10==cg10)
t10=0+p1;
pointcalculation();
}
void pointcalculation()
{
userspointtotal=t1+t2+t3+t4+t5+t6+t7+t8+t9+t10;
cout<<"You've scored "<< userspointtotal <<" points against the computer!"<<endl;
}
|