race !!!!

hi every body,
this is simple racing game.but every time shows one result(you lose).
how can i fix it ?
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
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <fstream>
#include <math.h>

using namespace std;
void main()
{
	int m,n,seed = rand();
	char k;
	cout<<"\n   choose your car "
		<<"\n   1: for BMW   "
		<<"\n   2: for TOYOTA\n\n   ";
	cin>>m;
	system("cls");
	switch (m)
	{
	case 1: 
		cout<<"\n       #######"
			<<"\n      /   |  ,\\\ "
			<<"\n  ####---------#####0"
			<<"\n  =--{}---------{}--#)";
		break;
	case 2: 
		cout<<"\n   #############"
			<<"\n   #     |      \\\ "
			<<"\n   #############0"
			<<"\n  =#^{}^^^^{}^^^#)";
		break;
	default:
		break;
	}
	cout<<"\n\n\n\n\   want a race ??   press 1 "
		<<"\n   exit press 2\n   ";
	cin>>n;
	system("cls");
	switch (n)
	{
	case 1: cout<<"\n   rcae finished"
				<<"\n   # to see the result press r "
				<<"\n   # to exit press e\n   ";
		cin>>k;
		system("cls");
		switch (k)
	   {
		case 'r':
			srand(seed);
			if ( ((rand()% 5)-1) == 0)
				cout<<"\n   You WIN";
			else 
				cout<<"\n   You LOSE";
			break;
		default:
		break;
	   }//swith (k)
		break;//case 1
	    default:
		break;
	 }//switch (n)
	_getch();
}
Last edited on
We don't play the "find the bug" game on this forum. What's the error or problem?
Topic archived. No new replies allowed.