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
|
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <time.h>
using namespace std;
struct RecAbbo{
std::string name;
std::string surname;
int games;
int won;
int same;
int lost;
int money;
}Abbo[100];
void play(int pl1, int pl2);
void game(int i);
int add(int i);
int main(){
srand (time(NULL));
int i = 1,choise;
bool exit = false;
while (!exit){
cout<<"1: add player \n";
cout<<"2: play a game \n";
cout<<"0: exit \n";
cout<<"choose: ";
cin>>choise;
switch (choise){
case 1:
i = add(i);
break;
case 2:
game(i);
break;
case 3:
exit = true;
break;
default:
cout<<"please rechoose \n";
}
}
}
int add(int i){
cout<<"name: ";
cin>>Abbo[i].name;
cout<<"surname: ";
cin>>Abbo[i].surname;
Abbo[i].games = 0;
Abbo[i].won = 0;
Abbo[i].same = 0;
Abbo[i].lost = 0;
Abbo[i].money = 0;
i++;
return i;
}
void game(int i){
cout<<"test ";
char name1[20],name2[20],surname1[20],surname2[20];
int i1, i2,j = 0;
i1 = rand() %100;
i2 = rand() %100;
while(i1 < 0 && i1 > 100){
if (i1 < 0)
i1 = i1 + rand() %100;
if (i1 > 100)
i1 = i1 - rand() %100;
}
while(i2 < 0 && i2 > 100){
if (i2 < 0)
i2 = i2 + rand() %100;
if (i2 > 100)
i2 = i2 - rand() %100;
}
while(i2 == i1)
i2 = i2 + rand() %100;
i2 = i2 - rand() %100;
cout<<i1<<" "<<i2;
}
void play(int pl1, int pl2){
int i, p1,p2,mode,p1money = 50, p2money = 50;
srand (time(NULL));
bool x = true,z = true;
while (x){
cout<<"for easy mode press 1 "<<endl;
cout<<"for normal mode press 2 "<<endl;
cout<<"for hard mode press 3 "<<endl;
cout<<"for beast mode press 4 "<<endl;
cout<<"choise: ";
cin>>mode;
switch (mode)
{
case 1:
i = rand() %100;
cout<<"number between 1 and 100"<<endl;
x=false;
break;
case 2:
i = rand() %500;
cout<<"number between 1 and 500"<<endl;
x=false;
break;
case 3:
i = rand() %2500;
cout<<"number between 1 and 2500"<<endl;
x=false;
break;
case 4:
i = rand() %10000;
cout<<"number between 1 and 10000"<<endl;
x=false;
break;
default:
cout<<"please choose again"<<endl;
break;
}
while(z){
cout<<"player 1: ";
cin>>p1;
cout<<"player 2: ";
cin>>p2;
if(p1 < i)
cout<<"number player 1 is higher"<<endl;
if(p1 > i)
cout<<"number player 1 is lower"<<endl;
if(p2 < i)
cout<<"number player 2 is higher"<<endl;
if(p2 > i)
cout<<"number player 2 is lower"<<endl;
if (p1 == i){
cout<<"player 1 has won!!"<<endl;
Abbo[pl1].won++;
Abbo[pl2].lost++;
Abbo[pl1].money = Abbo[pl1].money + p1money;
cout<<"money won for player 1: "<<p1money<<endl;
z = false;
} else {
p1money=p1money-5;
}
if (p2 == i){
cout<<"player 2 has won!!"<<endl;
Abbo[pl2].won++;
Abbo[pl1].lost++;
Abbo[pl2].money = Abbo[pl2].money + p2money;
cout<<"money won for player 2: "<<p2money<<endl;
z = false;
} else {
p2money=p2money-5;
}
if (p1money == 0 || p2money == 0){
Abbo[pl1].same++;
Abbo[pl2].same++;
}
}
}
}
| |