0
点赞
收藏
分享

微信扫一扫

三只小猪求体重(求最大值)

快乐小码农 2022-04-13 阅读 162
游戏程序

#include<iostream>
using namespace std;
int main()
{
    int arr[5] = { 300,350,400,250,500 };
    int max = 0;
    for (int i = 0; i < 5; i++)
    {
        if (arr[i] > max)
        {
            max = arr[i];
        }
    }
    cout << max << endl;
    system("pause");
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int arr[5] = { 300,350,400,250,500 };
    int max = 0;
    for (int i = 0; i < 5; i++)
    {
        arr[i] > max ? max = arr[i] : max = max;
    }
    cout<<max<<endl;
    system("pause");
    return 0;
}

举报

相关推荐

0 条评论