我需要爲學校作業創建一個紙牌遊戲,我試圖在輸出中顯示心臟,鑽石,黑桃和俱樂部符號。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;
}
你正在鍛鍊你解決問題的能力,它看起來並不重要。一旦有人開始向你支付高價錢,它會非常方便。 「俱樂部」意味着與「♣」完全相同的東西,所以沒有理由阻止這一點。弄清楚如何配置控制檯,使其使用正確的字體和代碼頁,這可以等待其他日子,並已經在這裏解決了許多現有的問題。 –