不知道该为函数的最后一个代码字符串写什么
cant figure out what to write for the last string of code for function
嗨,伙计们,这是我迄今为止对函数的了解,问题是让我写一个函数findpattern()
,它将接收代表三个保龄球得分的三个整数。该功能将确定这些分数所遵循的模式,打印以下六种情况之一(确保您有这六种情况):
stayed the same –- all three scores were the same
increasing –- the scores are going steadily upward
decreasing –- the scores are going steadily downward
up and down –- the scores first went up, then went down
down and up –- the scores first went down, then went up
two the same –- two consecutive scores were the same, and the
other one (first or third) was either higher or lower
这就是我到目前为止所拥有的,我不知道最后一部分,任何帮助都将不胜感激
void findpattern(int score1, int score2, int score3)
{
if (score1 == score2 && score1 == score3 && score2 == score3 )
{
cout << "all three scores were the same" << endl;
} else if (score1 < score2 && score2 < score3) {
cout << "the scores are going steadily upward" << endl;
} else if (score1 > score2 && score2 > score3) {
cout<<"the scores are going steadily downward"<<endl;
} else if(score1 < score2 && score2 > score3) {
cout << "the scores first went up, then went down" << endl;
} else if (score1 > score2 && score2 < score3) {
cout<<"the scores first went down, then went up"<<endl;
}
else if ( ( ( score1 == score2 ) && score2 != score3 ) || ( ( score2 == score3 ) && ( score2 != score1 ) ) )
cout << "two scores are equal" << endl;
你可以试试这个:
else if((score1==score2 || score2==score3) && ( (score1 > score3) || (score1 < score3)))
cout<<"two the same";
相关文章:
- 编译包含字符串的代码时遇到问题
- 为什么这个 c++ 代码打印出长度 5,当我打印出字符串时,程序会自动终止?
- 我应该如何修改此代码以使用给定字符串中的字母打印菱形图案
- 我无法在 qt 的C++代码中定义字符串
- 从 C 样式字符串中删除子字符串 "in place" 在C++代码中
- 有人可以解释一下这段代码如何能够反转字符串
- 如何在 c++ 非托管代码中反序列化 byte[] 的 json 字符串?
- 我遇到了这个代码片段,不明白. 它递归检查 C++ 字符串中是否存在大写字符
- 如何用符合C++核心准则的代码替换C风格的字符串解析
- C++/CLI访问字符串::来自非CLI代码的格式
- MSVC UTF8字符串编码使用了不正确的代码点
- C++指向对象的指针堆数组中,如何将字符串传递给特定对象?有一些代码请看一下:
- 将浮点数转换为字符串时如何加快此代码的速度?
- C++代码,用于在用户插入的字符串的每个元音之后插入一对字符
- 如何获取包含 NULL 字符的外壳代码字符串的长度
- 为什么 for 循环只接受这个简单代码中的最后一个字符串?
- 返回所有代码 - 字符串
- 我能做些什么来加速这个代码(字符串相似性)
- 不知道该为函数的最后一个代码字符串写什么
- 可以将代码字符串传递到c++宏中吗?