为帮助大家能在6月18日的比赛中有一个更好的成绩,我会将蓝桥杯官网上的历届决赛题目的四类语言题解都发出来。希望能对大家的成绩有所帮助。
今年的最大目标就是能为【一亿技术人】创造更高的价值。
资源限制
内存限制:256.0MB C/C++时间限制:1.0s Java时间限制:3.0s Python时间限制:5.0s
#include <bits/stdtr1c++.h>
using namespace std::tr1;
using namespace std;
int main()
{
int n;
cin >> n;
int sum = 0, tp;
int mx, mi;
mx = 0, mi = 100;
for (int i = 0; i < n; i++)
{
cin >> tp;
sum += tp;
mx = max(mx, tp);
mi = min(mi, tp);
}
unordered_map<int, int> ump;
printf("%d\n%d\n%.2f\n", mx + ump.size(), mi, 1.0 * sum / n + 1e-8);
return 0;
}
#include<stdio.h>
int main()
{
int i;
float p, max = -1, min = 1000;
float grades,av, sum = 0;
scanf("%f", &p);
for(i=0;i<p;i++)
{
scanf("%f", &grades);
if (grades < min)
min = grades;
if (grades > max)
max = grades;
sum += grades;
}
av = sum / p;
printf("%.0f\n%.0f\n%.2f", max, min,av);
return 0;
}
import java.io.*;
import java.math.BigDecimal;
public class Main {
static class Input{
StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() throws IOException{
in.nextToken();
return (int)in.nval;
}
}
public static void main(String args[]) throws Exception{
Input in = new Input();
int n = in.nextInt();
int sum = 0;
int max = 0;
int min = Integer.MAX_VALUE;
for(int i=0;i<n;i++) {
int s = in.nextInt();
if(s > max) {
max = s;
}
if(s < min) {
min = s;
}
sum +=s;
}
BigDecimal r = new BigDecimal(sum+"").divide(new BigDecimal(n+""), 2, BigDecimal.ROUND_HALF_UP);
System.out.println(max);
System.out.println(min);
System.out.println(r);
}
}
n = int(input())
lists = []
sum1 = 0
for i in range(0, n):
lists.append(int(input()))
for i in range(0, len(lists)):
sum1 += lists[i]
print(max(lists))
print(min(lists))
print('%0.2f' % (sum1/len(lists)))