7-1 摄氏温度转换华氏温度 分数 10 作者 翁恺 单位 浙江大学 温度刻画存在不同体系,摄氏度以1标准大气压下水的结冰点为0度,沸点为100度,将温度进行等分刻画。华氏度以1标准大气压下水的结冰点为32度,沸点为212度,将温度进行等分刻画。 根据华氏和摄氏温度定义,转换公式如下: C = ( F – 32 ) / 1.8 F = C * 1.8 + 32 输入格式: 一个不带小数点的数字,表示设摄氏温度。 输出格式: 一个表示华氏温度的数字。请直接采用print()输出计算结果,不需要对输出格式做处理。
时间: 2024-02-25 21:57:32 浏览: 114
根据题目要求,摄氏温度转换为华氏温度的公式为:
F = C * 1.8 + 32
其中,C表示摄氏温度,F表示华氏温度。
下面是Python代码实现:
```python
C = int(input()) # 输入摄氏温度
F = C * 1.8 + 32 # 摄氏温度转换为华氏温度
print(int(F)) # 输出华氏温度,不需要对输出格式做处理
```
在运行程序时,输入一个不带小数点的数字,即摄氏温度,程序将自动计算并输出对应的华氏温度。
相关问题
duplicated numbers 分数 10 作者 翁恺 单位 浙江大学 this program reads a lot
of integers and checks whether there are any duplicates. If there are duplicates, it prints "YES", otherwise it prints "NO". Here's the code:
```python
n = int(input())
a = list(map(int, input().split()))
s = set(a)
if len(a) != len(s):
print("YES")
else:
print("NO")
```
The program first reads in the number of integers `n`, and then reads in `n` integers. It then converts the input into a list `a`, and creates a set `s` from `a`. Since sets only contain unique elements, if the length of `a` is not equal to the length of `s`, it means that there are duplicates, and the program prints "YES". Otherwise, the program prints "NO".
6-3 Duplicated Numbers 分数 10 作者 翁恺 单位 浙江大学 This program reads a lot of integers, in which may be duplicated numbers. The program picks out all the duplicated ones and sorts the remainders in a descendent order. 函数接口定义: public static ArrayList<Integer> pi
ecewiseDuplicatedNumbers(int[] nums)
其中,
输入参数:
int[] nums :整型数组,表示输入的一组整数。
输出参数:
ArrayList<Integer> :整型数组列表,表示所有重复出现过的整数,按照降序排列。
示例:
输入:nums = {3, 1, 2, 3, 4, 5, 2, 4}
输出:[4, 3, 2]
解释:其中,4、3、2 都是重复出现过的整数,按照降序排列后,输出为 [4, 3, 2]。
算法思路:
1. 使用HashMap记录每个数字出现的次数;
2. 遍历HashMap,将出现次数大于1的数字加入到ArrayList中;
3. 对ArrayList进行降序排列,返回结果。
Java代码实现: