Hello Aftertimewaster,
After getting the code more readable I noticed:
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
|
#include<iostream>
#include <string>
using namespace std;
int main()
{
//srand((unsigned)time(0));
srand(static_cast<unsigned int>(time(nullptr)));
int x;
x = (rand() % 4) + 3;
int y;
y = (rand() % 4) + 3;
int Fcd;
Fcd = (rand() % 13) + 2;
int Scd;
Scd = (rand() % 13) + 2;
switch (Fcd)
{
case 11:
Fcd = 74;
break;
case 12:
Fcd = 81;
break;
case 13:
Fcd = 75;
break;
case 14:
Fcd = 65;
break;
}
switch (Scd)
{
case 11: Scd = 74;
break;
case 12: Scd = 81;
break;
case 13: Scd = 75;
break;
case 14: Scd = 65;
break;
}
int A;
while (Fcd < 10 && Scd < 10)
{
A = 1;
}
| |
Looking at lines 19 and 22 the "rand" will first return a number between (0 and 12) then you add 2 to that, so the lowest number this will return is 2.
In the switch statements you have nothing to deal with any of the other possible numbers or a default case. So you could leave the switch with "Fcd" and "Scd" having the random number first assigned and this may not be what you want.
In the first while loop if "Fcd" and "Scd" both happen to be less than 11 you end up with an endless while loop because "Fcd" and "Scd" never change.
Then I noticed:
|
cout << " "; cout << (char)201 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)187;
| |
You could write that as:
|
cout << " " << (char)201 << std::string(24, (char)205) << (char)187;
| |
It would save you a lot of work in the end.
It is Unnecessary for a "cout" statement for each line, but when you do
cout << " "; cout << (char)201
it is hard to read and easy to miss that there are 2 "cout" statements in 1 line.
The standard string is usually written as
std::string(24, '-')
. This is the standard string's fill constructor and creates a string with a size of 24 and fills all those elements with the minus sign. Be careful not all consoles could print the same character. A different type face could give (205) a completely different character or nothing printable.
Before your last switch you have:
1 2 3 4 5 6 7
|
cout << "\n "; cout << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
cout << "\n "; cout << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
cout << "\n "; cout << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
cout << "\n "; cout << (char)179 << " " << (char)x << " " << (char)179 << " " << (char)179 << " " << (char)y << " " << (char)179;
cout << "\n "; cout << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
cout << "\n "; cout << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
cout << "\n "; cout << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
| |
You could simplify that to:
1 2 3 4 5 6 7 8
|
std::cout
<< "\n " << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179
<< "\n " << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179
<< "\n " << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179
<< "\n " << (char)179 << " " << (char)x << " " << (char)179 << " " << (char)179 << " " << (char)y << " " << (char)179
<< "\n " << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179
<< "\n " << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179
<< "\n " << (char)179 << " " << (char)179 << " " << (char)179 << " " << (char)179;
| |
As you can see they both produce the same output:
│ │ │ │
│ │ │ │
│ │ │ │
│ A │ │ K │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ A │ │ K │
│ │ │ │
│ │ │ │
│ │ │ │
Press Enter to continue:
|
Andy