我需要为学校作业创建一个纸牌游戏,我试图在输出中显示心脏,钻石,黑桃和俱乐部符号。C++心脏,黑桃,俱乐部,钻石字符没有显示
老师告诉我们使用char(3),char(4)等,但输出显示一个问号。我在Windows 10上使用Visual Studio 2017.
我对Unicode或ASCII码不太熟悉,如果有人可以帮我解决,我还有3天的时间来完成这项任务!我是一个初学者
谢谢
//对于COMP 218条EC(2017年冬) - 肯考迪亚大学
cout << char(3) << char(4) << char(5) << char(6) << char(3) << char(4) << char(5) << char(6) << char(3) << char(4) << char(5) << char(6) << endl
<< "\t \t Welcome to Shawn's Card Dealing Program" << endl
<< char(3) << char(4) << char(5) << char(6) << char(3) << char(4) << char(5) << char(6) << char(3) << char(4) << char(5) << char(6);
cout << "RULES: \nTwo cards are dealt at a time. They are then compared. \nSince there are two decks of cards, you may have identital cards. \nI will tell you if they are the same or not" << endl
<< "or if they just have the same suit or rank. \nOnce I finish comparing the two cards, they are returned to the deck, the deck is reshuffled and two more cards are dealt. \n \n" << endl
<< "So how many pairs shall I deal? (1 to 15 max): \n > ";
while (!valid)
{
valid = true;
cin >> loops;
if (cin.fail() || loops < 1 || loops > 15)
{
cin.clear();
cin.ignore();
cout << "Please enter an integer between 1 and 15:" << endl << "> ";
valid = false;
}
}
int pairCount = loops;
do
{
card1.genRandom();
card2.genRandom();
cout << "Pair " << setw(2) << pairCount - loops + 1 << " - ";
card1.printCard();
card2.printCard();
cout << endl;
if (card1.sameCard(card2) == true)
{
cout << "same card" << endl;
ident += 1;
}
else
{
if (card1.sameSuit(card2) == true)
{
cout << "same suit" << endl;
sameSuit +=1;
}
if (card1.sameRank(card2) == true)
{
cout << "same rank" << endl;
sameRank += 1;
}
if (card1.sameRank(card2) == false && card1.sameSuit(card2) == false)
{
cout << "both different" << endl;
different +=1;
}
}
loops -= 1;
} while (loops > 0);
cout << "Identical: " << ident << endl;
cout << "Same Suit: " << sameSuit << endl;
cout << "Same Rank: " << sameRank << endl;
cout << "Both different: " << different << endl;
}
你正在锻炼你解决问题的能力,它看起来并不重要。一旦有人开始向你支付高价钱,它会非常方便。 “俱乐部”意味着与“♣”完全相同的东西,所以没有理由阻止这一点。弄清楚如何配置控制台,使其使用正确的字体和代码页,这可以等待其他日子,并已经在这里解决了许多现有的问题。 –