zoukankan      html  css  js  c++  java
  • (HDU)1673 -- Optimal Parking (停车位)

    题目链接:https://vjudge.net/problem/HDU-1673

    读懂你就知道...找出极差,乘上2倍就是最小距离

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <cmath>
     4 #include <iostream>
     5 #include <algorithm>
     6 #include <string>
     7 #include <cstdlib>
     8 
     9 using namespace std;
    10 
    11 int main()
    12 {
    13     int t,n,i,temp;
    14     scanf("%d",&t);
    15     while(t--)
    16     {
    17         scanf("%d",&n);
    18         int maxNum=0,minNum=100000;
    19         for(i=1;i<=n;i++)
    20         {
    21             scanf("%d",&temp);
    22             if(temp>maxNum) maxNum=temp;
    23             if(temp<minNum) minNum=temp;
    24         }
    25         printf("%d
    ",(maxNum-minNum)*2);
    26     }
    27 }
  • 相关阅读:
    Java的学习笔记(二)
    Java的学习笔记
    简单界面生成
    登录界面
    播放器
    java计划
    求和
    修改后的抽奖系统
    第十周作业
    JAVA第五次作业
  • 原文地址:https://www.cnblogs.com/ACDoge/p/6141874.html
Copyright © 2011-2022 走看看