codingame (一)--Temperatures(base)

这篇博客介绍了如何在Codingame平台上解决一个温度分析问题,目标是找到最接近0的温度记录。博主提供了C++代码实现,通过排序和条件判断来确定最接近0的值。代码中使用了vector和sort函数,并讨论了处理特殊情况的策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The Goal:

In this exercise, you have to analyze records of temperature to find the closest to zero.

Sample temperatures Here, -1 is the closest to 0.

Rules:

Write a program that prints the temperature closest to 0 among input data. If two numbers are equally close to zero, positive integer has to be considered closest to zero (for instance, if the temperatures are -5 and 5, then display 5).

我的代码:

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
vector<int> element;

int search(vector<int> &sch){
  &n

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值