鱼C论坛

 找回密码
 立即注册
查看: 1287|回复: 2

大神帮帮我

[复制链接]
发表于 2021-12-1 19:36:47 From FishC Mobile | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
1.从键盘上录入学生个数
2.依次录入学生学号、语文、数学、英语成绩
3.输入完成后,显示学号成绩及总分
4.设计排序系统:
输入1:按语文降序         输入2:按数学降序         输入3:按英语降序         输入4:按总分降序 输入5:按语文升序         输入6:按数学升序         输入7:按英语升序         输入8:按总分升序
输入其他大于0的数字:提示输入1-8
输入负数:退出查询
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-12-9 03:23:51 | 显示全部楼层
  1. dictname = {}
  2. one_result = []
  3. two_result = []
  4. three_result =[]
  5. sum_result=[]
  6. count = []
  7. while True:

  8.     print("1.从键盘上录入学生个数")
  9.     print("2.依次录入学生学号、语文、数学、英语成绩")
  10.     print("3.输入完成后,显示学号成绩及总分")
  11.     print("4.设计排序系统")
  12.     print("输入负数:退出查询")

  13.     cmd = eval(input("请输入命令"))

  14.     if cmd == 1:
  15.         number = eval(input("请输入需要录入的学生个数:"))
  16.         for i in range(number):
  17.             data = input("请输入学号,语文,数学,英语成绩,(每项用逗号分开)").split(",")
  18.             count.append(data[0])
  19.             one = int(data[1])
  20.             two = int(data[2])
  21.             three = int(data[3])
  22.             one_result.append(one)
  23.             two_result.append(two)
  24.             three_result.append(three)
  25.             sum = one+two+three
  26.             sum_result.append(sum)
  27.             dictname[data[0]] = [one,two,three,sum]

  28.         print("{}     {}     {}     {}     {}".format("学号","语文","数学","英语","总分"))
  29.         for j in count:
  30.             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))
  31.         print(dictname)


  32.     elif cmd == 4:
  33.         print("输入1:按语文降序\n"
  34.               "输入2:按数学降序\n"
  35.               "输入3:按英语降序\n"
  36.               "输入4:按总分降序\n"
  37.               "输入5:按语文升序\n"
  38.               "输入6:按数学升序\n"
  39.               "输入7:按英语升序\n"
  40.               "输入8:按总分升序")
  41.         number = eval(input("请输入命令"))
  42.         if number > 8 :
  43.             print("命令输入错误")
  44.             continue
  45.         elif number<0:
  46.             break
  47.         else:

  48.             if number == 1:
  49.                     new_result = one_result
  50.                     new_result.sort(reverse=True)
  51.                     print("{}     {}     {}     {}     {}".format("学号","语文","数学","英语","总分"))
  52.                     for i in new_result:
  53.                         for j in count:
  54.                             if i==dictname[j][0]:
  55.                                 print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))
  56.             elif number == 2:
  57.                 new_result = two_result
  58.                 new_result.sort(reverse=True)
  59.                 print("{}     {}     {}     {}     {}".format("学号","语文","数学","英语","总分"))
  60.                 for i in new_result:
  61.                     for j in count:
  62.                         if i==dictname[j][1]:
  63.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))

  64.             elif number == 3:
  65.                 new_result = three_result
  66.                 new_result.sort(reverse=True)
  67.                 print("{}     {}     {}     {}     {}".format("学号", "语文", "数学", "英语", "总分"))
  68.                 for i in new_result:
  69.                     for j in count:
  70.                         if i==dictname[j][2]:
  71.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))

  72.             elif number == 4:

  73.                 new_result = sum_result
  74.                 new_result.sort(reverse=True)
  75.                 print("{}     {}     {}     {}     {}".format("学号", "语文", "数学", "英语", "总分"))
  76.                 for i in new_result:
  77.                     for j in count:
  78.                         if i==dictname[j][3]:
  79.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))

  80.             elif number == 5:
  81.                 new_result = one_result
  82.                 new_result.sort()
  83.                 print("{}     {}     {}     {}     {}".format("学号","语文","数学","英语","总分"))
  84.                 for i in one_result:
  85.                     for j in count:
  86.                         if i==dictname[j][0]:
  87.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))

  88.             elif number == 6:
  89.                 new_result = two_result
  90.                 new_result.sort()
  91.                 print("{}     {}     {}     {}     {}".format("学号","语文","数学","英语","总分"))
  92.                 for i in two_result:
  93.                     for j in count:
  94.                         if i==dictname[j][1]:
  95.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))
  96.             elif number == 7:
  97.                 new_result = three_result
  98.                 new_result.sort()
  99.                 print("{}     {}     {}     {}     {}".format("学号","语文","数学","英语","总分"))
  100.                 for i in three_result:
  101.                     for j in count:
  102.                         if i==dictname[j][2]:
  103.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))

  104.             elif number == 8:
  105.                 new_result = sum_result
  106.                 new_result.sort()
  107.                 print("{}     {}     {}     {}     {}".format("学号", "语文", "数学", "英语", "总分"))
  108.                 for i in sum_result:
  109.                     for j in count:
  110.                         if i==dictname[j][3]:
  111.                             print("{}     {}      {}      {}      {}".format(j,dictname[j][0],dictname[j][1],dictname[j][2],dictname[j][3]))
  112.     if cmd<0:
  113.         break
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-12-9 03:24:33 | 显示全部楼层
简陋版,没做异常处理,没做函数封装,没做数据库保存的简陋版本,将就看下呗
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-25 21:42

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表