当前位置:网站首页>五只小猪的案例(五只小猪 比较体重的大小)
五只小猪的案例(五只小猪 比较体重的大小)
2022-07-30 15:13:00 【51CTO】
#include<iostream>
using namespace std;
int main() {
int arr[5]= { 100,200,300,400,50 };
int max = 0;//先认定最大值是下标为0 的100
for(int i = 0; i < 5; i++) {
if (arr[i] > max) {
//如果更新的元素大于我认定的最大值,就更新最大值
max = arr[i];
}
}
cout << "小猪的最大体重为:" << max << endl;//要放到最外面 ,因为在for循环里会把每次赋值的数打印出来
system("pause");
return 0;
}
边栏推荐
猜你喜欢
随机推荐
科研中一些常用软件清单
深度学习遇到报错Bug解决方法(不定时更新)
481-82(105、24、82、34、153)
How to split microservices?
MySQL客户端工具的使用与MySQL SQL语句
InputStream和OutputStream流的使用
golang图片处理库image简介
Shell脚本的概念
yarn的安装及使用教程
Mysql数据库查询好慢,除了索引,还能因为什么?
tiup env
Introduction to kasini3000
【喂到嘴边了的模块】准备徒手撸GUI?用Arm-2D三分钟就够了
[Cloud native] Grayscale release, blue-green release, rolling release, grayscale release explanation
2022最新 | 室外单目深度估计研究综述
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
How is the B+ tree index page size determined?
微服务架构下的核心话题 (二):微服务架构的设计原则和核心话题
[Cloud Native] Service Industry Case - Solutions for Unpredictable Concurrency Scenarios
TiUP 简介








