#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N=4;
int a[N]={3,3,3,5};
float s=0;
int main()
{
if(N==2){
if(a[0]==a[1]){
cout << a[0]; //相同电池全部ok
}else{
cout << 3; //1个3h和1个5h的只能用3h
}
}else{
for(int i=0;i<N;i++){
s+= a[i]; //剩下可以完全使用 => 1份时间=2份电
}
s = (s*1.0)/2;
printf("%.1f",s);
}
return 0;
}
//cout << "输入:"
练习7 - 电池的寿命
最新推荐文章于 2025-05-10 21:48:47 发布