⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pex3_8.cpp

📁 数据结构C++代码,经典代码,受益多多,希望大家多多支持
💻 CPP
字号:
#include <iostream.h>
#pragma hdrstop

#include "wex3_8.h"

void main(void)
{
	CardDeck d;
	int card[5], nextcardval;
	int correctguess = 0;
	char guess;
	
	// deal 5 cards
	for(int i=0;i < 5;i++)
		card[i] = d.GetCard();
		
	cout << "Cards are ordered clubs, diamonds, hearts, spades with ace low"
		 << endl << endl;
	// play the game
	for(i=0;i < 5;i++)
	{
		cout << "Player's card is  ";
		d.PrintCard(card[i]);
		cout << "Will the next card be higher ('H') or lower ('L') ";
		cin >> guess;
		nextcardval = d.GetCard();
		cout << "Next card is  ";
		d.PrintCard(nextcardval);
				
		if (nextcardval > card[i])
		{
			cout << "   Higher" << endl << endl;
			if (guess == 'H')
				correctguess++;
		}
		else
		{
			cout << "   Lower" << endl << endl;
			if (guess == 'L')
				correctguess++;
		}	
	}
	cout << "Number of correct guesses is " << correctguess << endl;
}

/*
<Run>

Cards are ordered clubs, diamonds, hearts, spades with ace low

Player's card is  2 of clubs
Will the next card be higher ('H') or lower ('L') H
Next card is  6 of diamonds
   Higher

Player's card is  Ace of spades
Will the next card be higher ('H') or lower ('L') L
Next card is  10 of spades
   Higher

Player's card is  5 of clubs
Will the next card be higher ('H') or lower ('L') H
Next card is  Jack of diamonds
   Higher

Player's card is  6 of clubs
Will the next card be higher ('H') or lower ('L') H
Next card is  Queen of hearts
   Higher

Player's card is  Queen of spades
Will the next card be higher ('H') or lower ('L') L
Next card is  Ace of clubs
   Lower

Number of correct guesses is 4
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -