我的代码什么都没有。 [英] My code returns nothing.

查看:96
本文介绍了我的代码什么都没有。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我的代码直接进入按任意键继续......然后关闭。我是一个相当新的编码,所以原谅我的stupedness,无论如何是的,我尝试添加返回0;无处不在,它仍然无法正常工作。请帮助!!!



Please help my code goes straight to "Press any key to continue..." then it closes. I am fairly new to coding so excuse my stupedness, anyways yeah I tried adding return 0; everywhere and it still just doesn't work. PLEASE HELP!!!

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <windows.h>

using namespace std;

int rouletteGen();

int main()
{	
	//--------
	//| Idea |
	//--------
	//cout << box 1 << box 2 << endl;

	int wheel, a, b, c, time, cA, cB, cC;
	a = 0;
	b = 0;
	c = 0;
	time = 500;

	while (a > 1)
	{
		cC = rouletteGen();
		if (cC >= 0 && cC <= 15)
		{
			cC = 1;
		}
		else if (cC >= 16 && cC <= 30)
		{
			cC = 2;
		}
		else if (cC == 31)
		{
			cC = 0;
		}
		cout << "          _l_" << endl;
		cout << "          \l/" << endl;
		cout << "_______ _______ _______" << endl;
		cout << "I     I I     I I    I" << endl;
		cout << "I  "<< " " <<"  I I  "<< " " <<"  I I  "<< cC<<"   I" << endl;
		cout << "I     I I     I I    I" << endl;
		cout << "_______ _______ _______" << endl;

		Sleep(250);
		c++;
		while (b > 1)
		{
			cB = cC;
			cC = rouletteGen();
			if (cC >= 0 && cC <= 15)
			{
				cC = 1;
			}
			else if (cC >= 16 && cC <= 30)
			{
				cC = 2;
			}
			else if (cC == 31)
			{
				cC = 0;
			}
			cout << "          _l_" << endl;
			cout << "          \l/" << endl;
			cout << "_______ _______ _______" << endl;
			cout << "I     I I     I I     I" << endl;
			cout << "I  " << " " << "  I I  " << cB << "  I I  " << cC << "   I" << endl;
			cout << "I     I I     I I     I" << endl;
			cout << "_______ _______ _______" << endl;

			cin.get();
			c++;
			Sleep(250);
			while (c >= 15)
			{
				cA = cB;
				cB = cC;
				cC = rouletteGen();
				if (cC >= 0 && cC <= 15)
				{
					cC = 1;
				}
				else if (cC >= 16 && cC <= 30)
				{
					cC = 2;
				}
				else if (cC == 31)
				{
					cC = 0;
				}
				cout << "          _l_" << endl;cout << "          \l/" << endl;
				cout << "_______ _______ _______" << endl;
				cout << "I     I I     I I     I" << endl;
				cout << "I  " << cA << "  I I  " << cB << "  I I  " << cC << "   I" << endl;
				cout << "I    I I     I I     I" << endl;
				cout << "_______ _______ _______" << endl;
				Sleep(time);
				time += 100;
				return 0;
			}
			return 0;
		}
		return 0;
	}
	return 0;
}

int rouletteGen()
{
	int dice;
	srand(time(NULL));
	dice = rand() % 31;

	dice = dice + 1;

	return dice;

}

推荐答案

a = 0;
 
while (a > 1)





在while循环中,a为0,因此永远不会是> 0所以你的循环永远不会执行,它向右返回0.



At the point of the while loop a is 0, so will never be > 0 so your loop never executes and it goes right to return 0.


你有一个而(a> 1)评估从一开始就 false ,因为你在开头设置了 a = 0;
You have a while (a > 1) which evaluates to false right from the start because you set a = 0; at the beginning.


这篇关于我的代码什么都没有。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆