Nov 16, 2015 at 6:42pm UTC
I've tried to make a codebreaking game but cant create loops that work help please.
#
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
include <iostream>
#include <cstdio>
#include <stdlib.h>
using namespace std;
int code, code2, code3, code4, g, g2, g3, g4;
bool correct(false );
int main()
{
cout << "Codemaker choose your first number\n" << flush;
cin >> code;
system ("CLS" );
cout << "Codemaker choose your second number\n" << flush;
cin >> code2;
system ("CLS" );
cout << "Codemaker choose your third number\n" << flush;
cin >> code3;
system ("CLS" );
cout << "Codemaker choose your forth number\n" << flush;
cin >> code4;
system ("CLS" );
cout << "Codebreaker guess your first number" ;
cin >> g;
if (code!=g)
{
cout << "Codebreaker guess your first number" ;
cin >> g;
}
cout << "Codebreaker guess your second number" ;
cin >> g2;
if (code2!=g2)
{
cout << "Codebreaker guess your second number" ;
cin >> g2;
}
cout << "Codebreaker guess your third number" ;
cin >> g3;
if (code!=g3)
{
cout << "Codebreaker guess your third number" ;
cin >> g3;
}
cout << "Codebreaker guess your final number" ;
cin >> g4;
if (code!=g4)
{
cout << "Codebreaker guess your final number" ;
cin >> g4;
}
cout << "you have guessed the code that was\n" << g,g2,g3,g4;
return 0;
}
thanks,
James
Last edited on Nov 17, 2015 at 6:28pm UTC
Nov 17, 2015 at 6:35pm UTC
sorry I'm new to c++ thanks