英语学习笔记2019-11-22

本文深入探讨了计算机系统的组成,包括硬件(如控制单元、算术逻辑单元、存储单元等)和软件(如操作系统、应用软件)。此外,还详细解析了一个评分计算问题,通过去除最高和最低分来计算平均得分,展示了算法实现的多种方法。

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

英语学习笔记2019-11-22

Review

the composition of a computer system

1. Hardware

  • Control Unit -- instruction <-- program
  • ALU (Arithmetic & Logic Unit) -- operation (operator + operand(data))

        Control Unit + ALU = CPU (Central Processing Unit)

  • Storage Unit (Primary Memory, Secondary Storage)
  • Input Devices -- keyboard, mouse, microphone, webcam, scanner...
  • Output Devices -- display, printer, speaker, plotter....

2. Software

  • System Software -- OS (Operating System), Language Processor, DBMS...
  • Application Software

Today we're going to learn something about Algorithms and Data Structures.

Score Calculating Problem in Singing Competition

For each singer, 10 judges give ten scores.

Let's consider how to calculate the final score for each singer.

The highest and lowest scores will be eliminated, and the average of the remaining eight scores will be the final score.

1. input ten scores and save them in a list

Run the program and the result goes like this:

2. calculate the highest and lowest scores

Run the program and let's take a look at the result:

3. calculate the final score

"""
计算歌手最终得分
10个评委,10个分数
去掉一个最高分,去掉一个最低分
然后求出平均分作为歌手最终得分
"""

# 输入10个分数存放到列表里
scores = []
for i in range(10):
    score = float(input('scores[%d] = ' %i))
    scores.append(score)
    
print('scores =', scores)

# 求出最高分与最低分
max_score = scores[0]
for i in range(1, 10):
    if max_score < scores[i]:
        max_score = scores[i]
print('max_score = {}'.format(max_score))
    
min_score = scores[0]
for i in range(1, 10):
    if min_score > scores[i]:
        min_score = scores[i]
print('min_score = {}'.format(min_score))

# 计算歌手最终得分
sum_score = 0
for score in scores:
    sum_score += score
final_score = (sum_score - max_score - min_score) / (len(scores) - 2)
print('final_score = {:.2f}'.format(final_score))     

Run the program and the result goes like this:

Of course, this program can be optimized.

"""
计算歌手最终得分
10个评委,10个分数
去掉一个最高分,去掉一个最低分
然后求出平均分作为歌手最终得分
"""

# 输入10个分数存放到列表里
scores = []
for i in range(10):
    score = float(input('scores[%d] = ' %i))
    scores.append(score)
    
print('scores =', scores)

# 求出最高分与最低分
max_score = max(scores)
print('max_score = {}'.format(max_score))
    
min_score = min(scores)
print('min_score = {}'.format(min_score))

# 计算歌手最终得分
sum_score = 0
for score in scores:
    sum_score += score
final_score = (sum_score - max_score - min_score) / (len(scores) - 2)
print('final_score = {:.2f}'.format(final_score))     

The result is the same:

Actually, we can modify the program like this:

"""
计算歌手最终得分
10个评委,10个分数
去掉一个最高分,去掉一个最低分
然后求出平均分作为歌手最终得分
"""

# 输入10个分数存放到列表里
scores = []
for i in range(10):
    score = float(input('scores[%d] = ' %i))
    scores.append(score)
    
print('scores =', scores)

# 成绩排序
scores = sorted(scores)

# 求出最高分与最低分
print('max_score = {}'.format(scores[len(scores) - 1]))
print('min_score = {}'.format(scores[0]))

# 去掉最高分与最低分
scores.pop(len(scores) - 1)
scores.pop(0)

# 计算歌手最终得分
sum_score = 0
for score in scores:
    sum_score += score
final_score = sum_score / len(scores)
print('final_score = {:.2f}'.format(final_score))     

Let's take a look at the result:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

酒城译痴无心剑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值