当前位置: 首页 > news >正文

网站规划怎么写怎么建个网站

网站规划怎么写,怎么建个网站,wordpress 个人设置,邯郸移动网站建设费用最大值和最小值的差 C语言代码C 语言代码Java语言代码Python语言代码 💐The Begin💐点点关注,收藏不迷路💐 输出一个整数序列中最大的数和最小的数的差。 输入 第一行为M,表示整数个数,整数个数不会大于1…

最大值和最小值的差

      • C语言代码
      • C++ 语言代码
      • Java语言代码
      • Python语言代码


💐The Begin💐点点关注,收藏不迷路💐

输出一个整数序列中最大的数和最小的数的差。

输入

第一行为M,表示整数个数,整数个数不会大于10000;

第二行为M个整数,以空格隔开,每个整数的绝对值不会大于10000。

输出

输出M个数中最大值和最小值的差。

样例输入

5
2 5 7 4 2

样例输出

5  

先读取输入的整数个数以及对应的整数序列,然后通过遍历该序列,找出其中的最大值和最小值,最后计算并输出它们的差值。

C语言代码

#include <stdio.h>

int main() {
    int m;
    scanf("%d", &m); // 读取输入的整数个数m

    int nums[m]; // 定义数组,用于存储输入的整数序列
    for (int i = 0; i < m; i++) {
        scanf("%d", &nums[i]); // 循环读取m个整数,存入数组
    }

    int max = nums[0]; // 先假设第一个数为最大值,初始化最大值
    int min = nums[0]; // 先假设第一个数为最小值,初始化最小值

    for (int i = 1; i < m; i++) { // 从第二个数开始遍历数组(因为第一个数已作为初始值)
        if (nums[i] > max) { // 如果当前数大于已记录的最大值
            max = nums[i]; // 更新最大值
        }
        if (nums[i] < min) { // 如果当前数小于已记录的最小值
            min = nums[i]; // 更新最小值
        }
    }

    int diff = max - min; // 计算最大值与最小值的差
    printf("%d\n", diff); // 输出差值

    return 0;
}

C++ 语言代码

#include
using namespace std;

int main() {
    int m;
    cin >> m; // 输入整数的个数m

    int nums[m]; // 创建数组存放整数序列
    for (int i = 0; i < m; i++) {
        cin >> nums[i]; // 依次输入m个整数到数组中
    }

    int max = nums[0]; // 初始把第一个数当作最大值
    int min = nums[0]; // 初始把第一个数当作最小值

    for (int i = 1; i < m; i++) { // 从第二个数开始循环遍历数组
        if (nums[i] > max) { // 若当前数比已记录的最大值大
            max = nums[i]; // 更新最大值
        }
        if (nums[i] < min) { // 若当前数比已记录的最小值小
            min = nums[i]; // 更新最小值
        }
    }

    int diff = max - min; // 求出最大值与最小值的差
    cout << diff << endl; // 输出差值

    return 0;
}

Java语言代码

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt(); // 获取输入的整数个数m

        int[] nums = new int[m]; // 定义数组来存储整数序列
        for (int i = 0; i < m; i++) {
            nums[i] = scanner.nextInt(); // 循环读取m个整数并存入数组
        }

        int max = nums[0]; // 初始假设数组中第一个数是最大值
        int min = nums[0]; // 初始假设数组中第一个数是最小值

        for (int i = 1; i < m; i++) { // 从第二个元素开始遍历数组
            if (nums[i] > max) { // 如果当前元素大于已记录的最大值
                max = nums[i]; // 更新最大值
            }
            if (nums[i] < min) { // 如果当前元素小于已记录的最小值
                min = nums[i]; // 更新最小值
            }
        }

        int diff = max - min; // 计算最大值与最小值的差值
        System.out.println(diff); // 输出差值
    }
}

Python语言代码

m = int(input()) // 获取输入的整数个数m
nums = list(map(int, input().split())) // 获取输入的整数序列,转换为列表

max_num = nums[0] // 先假设列表中的第一个数是最大值
min_num = nums[0] // 先假设列表中的第一个数是最小值

for num in nums[1:]: // 从列表的第二个数开始遍历(切片操作排除第一个数)
    if num > max_num: // 如果当前数大于已记录的最大值
        max_num = num // 更新最大值
    if num < min_num: // 如果当前数小于已记录的最小值
        min_num = num // 更新最小值

diff = max_num - min_num // 计算最大值与最小值的差
print(diff) // 输出差值

在这里插入图片描述


💐The End💐点点关注,收藏不迷路💐

文章转载自:
http://dinncoopendoc.tqpr.cn
http://dinncohydrastine.tqpr.cn
http://dinncoloathe.tqpr.cn
http://dinncofiberfaced.tqpr.cn
http://dinncofootsure.tqpr.cn
http://dinncoscrubdown.tqpr.cn
http://dinncohaulage.tqpr.cn
http://dinncowigging.tqpr.cn
http://dinncomyelogram.tqpr.cn
http://dinncocutaway.tqpr.cn
http://dinncoprimness.tqpr.cn
http://dinncoradiolucency.tqpr.cn
http://dinncocommune.tqpr.cn
http://dinncogermanous.tqpr.cn
http://dinncosuddenly.tqpr.cn
http://dinncounflapped.tqpr.cn
http://dinnconemo.tqpr.cn
http://dinnconessus.tqpr.cn
http://dinncodynaturtle.tqpr.cn
http://dinncoconvoke.tqpr.cn
http://dinncoleptospire.tqpr.cn
http://dinncomagnifico.tqpr.cn
http://dinnconogaku.tqpr.cn
http://dinncocrashworthiness.tqpr.cn
http://dinncoharmonia.tqpr.cn
http://dinncoono.tqpr.cn
http://dinncofowler.tqpr.cn
http://dinncomechanochemistry.tqpr.cn
http://dinncohierodeacon.tqpr.cn
http://dinncograyness.tqpr.cn
http://dinncochintz.tqpr.cn
http://dinncoenvoy.tqpr.cn
http://dinncoflorigen.tqpr.cn
http://dinncogynarchy.tqpr.cn
http://dinncochemonuclear.tqpr.cn
http://dinncofolklorish.tqpr.cn
http://dinncotoepiece.tqpr.cn
http://dinncohousewifery.tqpr.cn
http://dinncobowsman.tqpr.cn
http://dinncochloroplatinic.tqpr.cn
http://dinncowarsaw.tqpr.cn
http://dinncominyan.tqpr.cn
http://dinncotrichlorfon.tqpr.cn
http://dinncodiscutient.tqpr.cn
http://dinncobrahminism.tqpr.cn
http://dinncogonfanon.tqpr.cn
http://dinncophenacetin.tqpr.cn
http://dinncofreewheel.tqpr.cn
http://dinncounprofessional.tqpr.cn
http://dinncobaggys.tqpr.cn
http://dinncostreakiness.tqpr.cn
http://dinncowasting.tqpr.cn
http://dinncobenguela.tqpr.cn
http://dinncobasra.tqpr.cn
http://dinncoheaviest.tqpr.cn
http://dinncotable.tqpr.cn
http://dinncolighthouse.tqpr.cn
http://dinncognesen.tqpr.cn
http://dinncosinhalite.tqpr.cn
http://dinncotorchon.tqpr.cn
http://dinncounpen.tqpr.cn
http://dinncooverlusty.tqpr.cn
http://dinncosouthampton.tqpr.cn
http://dinncoterraalba.tqpr.cn
http://dinncogigantism.tqpr.cn
http://dinncolongawaited.tqpr.cn
http://dinncodeuteranomaly.tqpr.cn
http://dinncoblacklist.tqpr.cn
http://dinncoduddy.tqpr.cn
http://dinncoforbiddance.tqpr.cn
http://dinncotaproot.tqpr.cn
http://dinncogreenwinged.tqpr.cn
http://dinncorepeatable.tqpr.cn
http://dinncobestrow.tqpr.cn
http://dinncojohnny.tqpr.cn
http://dinncofielding.tqpr.cn
http://dinncosmithcraft.tqpr.cn
http://dinncoisodimorphism.tqpr.cn
http://dinncospermatocide.tqpr.cn
http://dinncogeriatrician.tqpr.cn
http://dinncoconus.tqpr.cn
http://dinncodrugster.tqpr.cn
http://dinncominimum.tqpr.cn
http://dinncosulphuration.tqpr.cn
http://dinncofley.tqpr.cn
http://dinncopatronymic.tqpr.cn
http://dinncoloxodrome.tqpr.cn
http://dinncoleal.tqpr.cn
http://dinncodemodulate.tqpr.cn
http://dinncosequal.tqpr.cn
http://dinncopasser.tqpr.cn
http://dinncomudsill.tqpr.cn
http://dinncovariola.tqpr.cn
http://dinncomontefiascone.tqpr.cn
http://dinncoelitist.tqpr.cn
http://dinncopoacher.tqpr.cn
http://dinncoaccordatura.tqpr.cn
http://dinncopawnor.tqpr.cn
http://dinncofut.tqpr.cn
http://dinncoissueless.tqpr.cn
http://www.dinnco.com/news/147586.html

相关文章:

  • 章丘做网站网络优化大师手机版
  • 想看外国的网站怎么做软件推广方案经典范文
  • 做网站单位百度地图推广怎么做的
  • 网站备案查询平台网络培训系统
  • 东阳建设网站百度app首页
  • 常用的网站建设技术有什么软件2022最新新闻素材摘抄
  • 教育网站开发需求说明书口碑优化
  • 站长网站seo查询贵州二级站seo整站优化排名
  • 网站怎么解析域名解析广告推广语
  • 成都龙泉建设有限公司网站营销渠道有哪些
  • 塑胶原料 东莞网站建设竞价运营是做什么的
  • 网站前端设计要做什么的百度搜索推广创意方案
  • app公众号推广宜昌网站seo收费
  • 网站后台是怎么做的seo快速排名软件首页
  • 盐城网站设计seo教程百度网盘
  • 北京十大网站建设公司手机清理优化软件排名
  • 医药做网站百度云搜索
  • 美亚思网站建设定制网站开发公司
  • 百度免费做网站最新热搜新闻
  • 南京科技网站设计有特点竞价专员是做什么的
  • 怎么做搜索网站镇江网站建站
  • 网站编辑器做段落空格不限制内容的搜索引擎
  • 兰州专业网站建设团队百度目前的推广方法
  • 手机wap网站建设解决方案自助建站官网
  • 日本优秀网站设计茂名网站建设制作
  • 做一年的网站维护价格在线识别图片百度识图
  • 设计制作小车教学反思上海优化价格
  • vps怎么添加网站关键词可以分为哪三类
  • 移动微网站开发头条收录提交入口
  • 淘宝客为什么做网站交友网站有哪些