如何从数据库中的一行中获取最高和最低标记 [英] How to get the highest and lowest mark from a row in the database

查看:48
本文介绍了如何从数据库中的一行中获取最高和最低标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出当用户单击搜索按钮时如何从数据库中的一行中获取最高和最低标记.我一直在尝试使用的代码不起作用,谁能告诉我哪里出错了.

I'm trying to work out how to get the highest and lowest mark from a row in the database when the user clicks the search button. The code I have been trying to use is not working can anyone tell me where I'm going wrong.

int max = A[0];
for (int i =1; 1 < A.length; i++)
{
if (A[i] > max)
{
max = A [i];
}
}
return (max);
}

总的来说,我希望用户输入学生 ID 并单击搜索按钮,然后将显示特定学生的最低和最高分.

Overall I expect the user to enter a students ID and click the search button and will then display that specific students lowest and highest mark.

推荐答案

试试这个

double[] marksArr=new Double[4];
marksArr[0]=5;
marksArr[1]=2;
marksArr[2]=7;
marksArr[3]=4;
Array.Sort(marksArr);
double min=marksArr[0];
double max=marksArr[marksArr.length];

这篇关于如何从数据库中的一行中获取最高和最低标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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