当前位置:网站首页>C语言经典习题之评委打分去掉最高最低求平均分
C语言经典习题之评委打分去掉最高最低求平均分
2022-07-24 04:18:00 【Serendipity_-】
青年歌手参加歌曲大奖赛,有10个评委对她进行打分,试编程求这位选手的平均得分(去掉一个最高分和一个最低分)
思路:从终端输入10个数并进行求和,两两比较找出最大值和最小值,用总和减去最大值和最小值除8即可得平均值
/*青年歌手参加歌曲大奖赛,有10个评委对她进行打分, 试编程求这位选手的平均得分(去掉一个最高分和一个最低分) 思路:从终端输入10个数并进行求和,两两比较找出最大值和最小值 用总和减去最大值和最小值除8即可得平均值 */
#include <stdio.h>
int main(int argc, char const *argv[])
{
printf("input:\n");
int i, j, n, t, arr[10];
float sum;
for (n = 0; n < 10; n++)
{
scanf("%d", &arr[n]);
}
for (i = 0; i < 10; i++)
{
for (j = 0; j < 9 - i; j++)
{
if (arr[j] > arr[j + 1])
{
t = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = t;
}
}
}
for (int a = 1; a < 9; a++)
{
sum += arr[a];
}
printf("average:%.2f\n", sum / 8);
return 0;
}
运行结果如下:
边栏推荐
- conda 常用命令
- Insider of LAN SDN hard core technology 22 Kang long regrets -- Specifications and restrictions (Part 2)
- Leetcode 204. count prime number (2022.07.23)
- What is the real HTAP? (2) Challenge article
- 发送数据1010_1发人员通过 字节的
- 组合数(阶乘的质因子的个数,组合数的计算)
- Listen for the scroll event @scroll of div
- MySQL service 1 master 2 slave, master master, MHA configuration detailed steps
- Extend the connection boundary, expand the business scope, and comprehensively move towards the era of Intelligent Cloud network 2.0
- Sqlserver backup restore
猜你喜欢

The second anniversary of open source, opengauss Developer Day 2022 full highlights review!
![[dish of learning notes, dog learning C] Dachang written test, is that it?](/img/4c/71c7268e40f0e2a15f52083022d565.png)
[dish of learning notes, dog learning C] Dachang written test, is that it?

Leetcode (Sword finger offer) - 11. Minimum number of rotation array
![[translation] announce krius -- accelerate your monitoring and adoption of kubernetes](/img/6c/be19a910e60da701a054c4bf689000.jpg)
[translation] announce krius -- accelerate your monitoring and adoption of kubernetes

Codeforces Round #808 (Div. 2) A - D
![Embedded system transplantation [6] - uboot source code structure](/img/dd/85e56360b08f49562a28ea6f6adcfd.png)
Embedded system transplantation [6] - uboot source code structure

What are the 10 live demos showing? It's worth watching again whether you've seen it or not

How does the trend chart of spot silver change?

The impact of Patrick mchardy incident on the open source community

MPLS VPN cross domain -optionb
随机推荐
(5) Digital electricity formula simplification method
Pyth去初始化平均在很多机器学决策边界,始向总线上
MPLS VPN cross domain -optionb
Analyze the real-time development method of Bank of London
[development technology] spingboot database and Persistence technology, JPA, mongodb, redis
Leetcode 20 valid parentheses, 33 search rotation sort array, 88 merge two ordered arrays (nums1 length is m+n), 160 intersecting linked list, 54 spiral matrix, 415 character addition (cannot be direc
值为 0 流程,另一部分看括但不限于如下这题是
Solution to the problem of "out of sight, out of mind, out of order" in the training competition
LAN SDN technology hard core insider 9 from software overlay to hardware overlay
6-14 vulnerability exploitation rpcbind vulnerability exploitation
[translation] announce krius -- accelerate your monitoring and adoption of kubernetes
Ambire gas tank launches exclusive NFT launch
IPhone binding 163 mailbox solution
一次 svchost.exe 进程占用大量网络带宽的排查
How to configure Ethernet network topology in canoe network based access mode
Redis sentinel mode, master node check script
PMIX ERROR: ERROR in file gds_ ds12_ lock_ pthread.c
PMIX ERROR: ERROR in file gds_ds12_lock_pthread.c
How did I get four offers in a week?
Shell syntax (1)