我可以得到输入,但之后我想不出好办法,我觉得还是把每个值都保存为双精度表,通过播放来使用处理for语句的方法比较好,但那样的话,你要把for门转3次,有没有更简单的方法,你能用Python解决这个问题,请帮帮我。
这是我的问题
**The question
**Oh-seok wants to buy a laptop. There are n kinds of laptops on display in the store.
Oh-seok is interested in cpu speed, RAM, and the size of hard disk. (FYI, I am not interested in specification of anything else.)
Oh-seok has a rule to buy a laptop.
Rule 1) If the specifications of one laptop are all lower than those of another laptop, the laptop is not bought because it is out of fashion.
Rule 2) Choose the cheapest laptop that is judged to be out of fashion.
There are so many laptops that Oh-seok tries to find a laptop that fits his condition by creating a program with coding.
Print out the number of the laptop you want to buy with the program Oh-seok made.
Input type
The first line is given the number of laptops (1≤n≤100)
From the second line, n lines are given the specifications of the laptop. Each line is given the laptop's specifications in order of cpu speed, RAM size, hard disk size, and price.
• 1,000≤cpu speed≤4,200
• 256≤Ram size≤4,096
• 1≤Hard disk size≤500
• 100≤Price≤1,000 (all laptops are priced differently).)
Output type
Print out the number of the laptop that Oseok will buy. The number of the laptop means the order of each line in which a given laptop specification is written in the input data.
Input/output example data
Input Example 1
5
2100 512 150 200
2000 2048 240 350
2300 1024 200 320
2500 2048 80 300
2000 512 180 150
'
N = int(input())
information = [[] * (N) for _ in range(N)] # laptop's information.
#input (cpu , ram , harddisk, price)
for _ in range(N):
tmp = list(map(int,input().split()))
for i in range(4):
information[i].append(tmp[i])
print(information)
'
This is my input code.
but I can't programming how to compare each others.
plz coding how to compare it.
2条答案
按热度按时间eufgjt7s1#
我看不出有什么更好的方法比详尽地比较每一台笔记本电脑与每一个其他的,在所有的标准,以检查是否一台机器是过时的。
如果一台机器过时了,你可以在下一次的比较中把它排除在外。
8hhllhi22#
这里有一个程序,通过创建一个评级系统,并排名不同的笔记本电脑“CPU + RAM + HDD -价格=排名值”找到最好的笔记本电脑
如果你想找到最差的笔记本电脑,你可以反过来说:“price - CPU - RAM - HDD =排名值”//也许你必须用 * 2调整之前的价格值。
如果CPU对您来说更重要,那么您可以使用如下乘数:“CPU * 0.2 + RAM +硬盘-价格=排名值”
不同的笔记本电脑规格存储在input.txt中,如下所示
我不是很习惯python,也许有一个更优雅的解决方案...