[ create a new paste ] login | about

Link: http://codepad.org/SCibPhBw    [ raw code | fork ]

axell13 - C++, pasted on Dec 9:
//Cassino

#include <Windows.h>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#undef max
using namespace std;

void main(){
	int dinheiro = 500;
	int aposta = 0;
	int numeros[9];
	int cont = 0;

	srand( (unsigned) time(NULL) );

	while (dinheiro >= 1){
		cont = 0;
		printf("--------- Dinheiro: %i ---------\n\n", dinheiro);
		printf("Quanto Deseja Apostar ? ");
		cin >> aposta;
		cin.sync();
		while (cin.fail()){
			cin.clear();
			cin.sync();
		}
		cin.ignore(numeric_limits <int>::max(), '\n');
		
		while (cin.fail() || aposta < 1 || aposta > dinheiro){
			system("cls");
			printf("--------- Dinheiro: %i ---------\n\n", dinheiro);
			printf("Quantia Invalida, Quanto Deseja Apostar ? ");
			cin >> aposta;
			cin.sync();
			if (cin.fail()){
				cin.clear();
				cin.sync();
			}
			cin.ignore(numeric_limits<int>::max(), '\n');
		}
		while (cont < 30){
			numeros[0] = rand() % 10;
			numeros[1] = rand() % 10;
			numeros[2] = rand() % 10;
			numeros[3] = rand() % 10;
			numeros[4] = rand() % 10;
			numeros[5] = rand() % 10;
			numeros[6] = rand() % 10;
			numeros[7] = rand() % 10;
			numeros[8] = rand() % 10;

			printf("%i    %i    %i\n\n%i    %i    %i\n\n%i    %i    %i", numeros[0], numeros[1], numeros[2], numeros[3], numeros[4], numeros[5], numeros[6], numeros[7], numeros[8]);
			if (cont == 29){

			}
			else{
				system("cls");
			}
			Sleep(20);
			cont++;
		}
		if (numeros[3] == numeros[4] && numeros[3] == numeros[5]){
			printf("\n\nParabens, Voce Venceu A Rodada");
			Sleep(5000);
			dinheiro += aposta;
			system("cls");
		}
		else{
			printf("\n\nQue Pena, Voce Perdeu A Rodada");
			Sleep(5000);
			dinheiro -= aposta;
			system("cls");
		}

	}

	cont = 0;
	while (cont < 5){
		printf("---------- GAME OVER ----------");
		Sleep(400);
		system("cls");
		Sleep(400);
		cont++;
	}

}


Create a new paste based on this one


Comments: