我可能在寻找一些东西,但在C++中是否有一种简单的方法可以将案例分组在一起而不是单独写出来?我记得基本上我可以做到:
SELECT CASE Answer
CASE 1, 2, 3, 4
Run Code Online (Sandbox Code Playgroud)
C++中的示例(对于那些需要它的人):
#include <iostream.h>
#include <stdio.h>
int main()
{
int Answer;
cout << "How many cars do you have?";
cin >> Answer;
switch (Answer)
{
case 1:
case 2:
case 3:
case 4:
cout << "You need more cars. ";
break;
case 5:
case 6:
case 7:
case 8:
cout << "Now you need a house. ";
break;
default:
cout << "What are you? A peace-loving hippie freak? ";
}
cout << …
Run Code Online (Sandbox Code Playgroud) 我正在努力让我的扑克来评估玩家手牌.我可以让Flush和千斤顶或更好的一对工作,但我遇到了问题,弄清楚我将如何做其余的事情.关于我如何评估卡到适当类型的任何建议?
int Game::HandCheck()
{
//ROYAL FLUSH
//return 9;
//STRAIGHT FLUSH
//return 8;
//FOUR OF A KIND
//return 7;
//FULL HOUSE
//return 6;
//FLUSH
if( currentHand[ 0 ].GetSuit() == currentHand[ 1 ].GetSuit() && currentHand[ 1 ].GetSuit() == currentHand[ 2 ].GetSuit() &&
currentHand[ 2 ].GetSuit() == currentHand[ 3 ].GetSuit() && currentHand[ 4 ].GetSuit() == currentHand[ 4 ].GetSuit() )
return 5;
//STRAIGHT
//return 4;
//THREE OF A KIND
if( currentHand[ 0 ].GetValue() == currentHand[ 2 ].GetValue() && currentHand[ 0 ].GetValue() == currentHand[ 3 …
Run Code Online (Sandbox Code Playgroud) 这就是我到目前为止所得到的错误.有帮助吗?
void ReverseString(char* string) {
int len = strlen(string);
for(int i = 0; i < len; i++)
{
string[i] = string[len-i];
}
}
Run Code Online (Sandbox Code Playgroud) 谁能告诉我为什么我的上一次出现错误cout
?
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <conio.h>
using namespace std;
inline void keep_window_open() { char ch; cin>>ch; }
int main()
{
cout << "How many pennies do you have?\n";
int pennies;
cin >> pennies;
double total_pen;
total_pen = (0.01 * pennies);
if (pennies >= 1)
{
string penn = " pennies.";
}else
{
string penn = " penny.";
} cout << "How many nickles do you have?\n";
int nickles;
cin >> nickles;
double total_nic; …
Run Code Online (Sandbox Code Playgroud)