找出“第二高”的学生平均分 [英] Figuring out 'second highest' student average

查看:89
本文介绍了找出“第二高”的学生平均分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi umm

i需要帮助用c(或c ++)编写程序

这里有详细信息:



i希望它收到x学生ID的数量和上一学期学生的平均数

我想让它告诉我谁是第二好的

(谁拥有第二高的平均值)**

只需使用for和如果和同时和做......同时和其他如果

有人可以帮助我,因为它很紧急。

i非常感谢它。

这里是我的意思到目前为止

hi umm
i need help in writing a program in c(or c++)
here are the details:


i want it to recieve "x" numbers of student id''s and the average of the student in their last term
and i want it to tell me who was second best
(who has the second highest average )**
just using "for" and "if" and "while" and "do...while" and "else if"
can somebody please help me as it is urgent.
i would very much appreciate it.
here is what i have so far

展开 | 选择 | Wrap | 行号

推荐答案

嗯,您的代码只读取2个平均值。你是如何阅读数据的?是手动输入还是按文件输入?如果你可以让它们输入数字,你可以使用那么多元素初始化一个数组,然后将它作为for循环的最大条件来读取它们。如果它在文件中,你可以循环访问文件(取决于它是如何分隔的 - 如果它是每一行,你可以得到行数并使用它,否则你可以扫描并读取有多少分隔符并使用它。)


所以你应该首先决定你将如何计算你将要阅读的平均数。然后你必须稍微修改你的代码,我'' d推荐具有当前前2个平均值的临时变量。 (因为你可能有一个是新的顶部,你的顶部现在是你的第二个,或新的第二个)。
Well, your code only reads in 2 averages. How are you reading in the data? Is it input manually, or by file? If you can have them input the number, you can initialize an array with that many elements, and then use that as the max condition in a for loop to read them in. If it''s in a file, you can cycle through the file (depending on how it is delimited - if it''s each line, you can get a line count and use that, or else you can scan through and read how many delimiters there are and use that).

So you should start by deciding how you are going to figure out how many averages you''re going to be reading in. Then you''ll have to modify your code a little bit, I''d recommend a temp variable with the "current top 2 averages" (as you may have one that is either the new top, and your top is now your second, or the new second).



好吧,你的代码只读取2个平均值。你是如何阅读数据的?是手动输入还是按文件输入?如果你可以让它们输入数字,你可以使用那么多元素初始化一个数组,然后将它作为for循环的最大条件来读取它们。如果它在文件中,你可以循环访问文件(取决于它是如何分隔的 - 如果它是每一行,你可以得到行数并使用它,否则你可以扫描并读取有多少分隔符并使用它。)


所以你应该首先决定你将如何计算你将要阅读的平均数。然后你必须稍微修改你的代码,我'' d推荐具有当前前2个平均值的临时变量。 (因为你可能有一个是新的顶部,而你的顶部现在是你的第二个,或者新的第二个)。
Well, your code only reads in 2 averages. How are you reading in the data? Is it input manually, or by file? If you can have them input the number, you can initialize an array with that many elements, and then use that as the max condition in a for loop to read them in. If it''s in a file, you can cycle through the file (depending on how it is delimited - if it''s each line, you can get a line count and use that, or else you can scan through and read how many delimiters there are and use that).

So you should start by deciding how you are going to figure out how many averages you''re going to be reading in. Then you''ll have to modify your code a little bit, I''d recommend a temp variable with the "current top 2 averages" (as you may have one that is either the new top, and your top is now your second, or the new second).



这就是问题。我不想使用arrays.first,我不允许。而问题本身就说只使用for和while和类似的简单东西。

你可以看到用户自己必须输入学生人数,然后输入学生人数并逐个平均!

我希望程序找到它的平均值是第二高的。它可以了。

well thats the problem.i dont want to use arrays.first of all im not allowed to.and the question itself says using only for and while and similar simple stuff.
and as u can see the user themself has to enter the number of students and then the student number and average one by one!
and i want the program to find out who has the second highest average.thats it.


看起来我到了这里。但它似乎有一些逻辑问题。请你帮助我?我卡住了
look i got up to here.but it seems to have some logical problems.can u please help me?im stuck
展开 | 选择 | Wrap | → ine数字


这篇关于找出“第二高”的学生平均分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆