C#程序设计实验报告.docx
《C#程序设计实验报告.docx》由会员分享,可在线阅读,更多相关《C#程序设计实验报告.docx(60页珍藏版)》请在冰豆网上搜索。
C#程序设计实验报告
实验报告书写要求
实验报告原则上要求学生手写,要求书写工整。
若因课程特点需打印的,标题采用四号黑体,正文采用小四号宋体,单倍行距。
纸张一律采用A4的纸张。
实验报告书写说明
实验报告中实验目的和要求、实验仪器和设备、实验内容与过程、实验结果与分析这四项内容为必需项。
教师可根据学科特点和实验具体要求增加项目。
填写注意事项
(1)细致观察,及时、准确、如实记录。
(2)准确说明,层次清晰。
(3)尽量采用专用术语来说明事物。
(4)外文、符号、公式要准确,应使用统一规定的名词和符号。
(5)应独立完成实验报告的书写,严禁抄袭、复印,一经发现,以零分论处。
实验报告批改说明
实验报告的批改要及时、认真、仔细,一律用红色笔批改。
实验报告的批改成绩采用五级记分制或百分制,按《金陵科技学院课堂教学实施细则》中作业批阅成绩评定要求执行。
实验报告装订要求
实验批改完毕后,任课老师将每门课程的每个实验项目的实验报告以自然班为单位、按学号升序排列,装订成册,并附上一份该门课程的实验大纲。
实验项目名称:
C#基础编程实验学时:
6
同组学生姓名:
实验地点:
1318
实验日期:
10月5日-10月19日实验成绩:
批改教师:
批改时间:
实验1C#基础编程
一、实验目的
1、熟悉VisualStudio.NET开发环境。
2、掌握C#应用程序的基本操作过程。
3、掌握C#的数据类型,运算符以及表达式的使用。
4、掌握分支和循环语句的使用方法。
5、掌握一维数组,二维数组及数组型数组的使用。
二、实验要求
(1)编写程序要规范、正确,上机调试过程和结果要有记录
(2)做完实验后给出本实验的实验报告。
三、实验设备、环境
安装有VisualStudio.NET软件。
四、实验步骤
1、分析题意。
2、根据题目要求,新建项目。
3、编写并输入相关的程序代码。
5、运行与调试项目。
6、保存项目。
五、实验内容
1、编写一个简单的控制台应用程序,打印一行文字(如你的姓名)。
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
namespaceone.first
{
classProgram
staticvoidMain(string[]args)
System.Console.WriteLine("我叫王蕾!
");
}
2、编写一个简单的Windows应用程序,在窗体Load事件中书写代码,标签中显示你的姓名。
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Windows.Forms;
namespaceone.second
publicpartialclassForm1:
Form
publicForm1()
InitializeComponent();
privatevoidForm1_Load(objectsender,EventArgse)
this.Text="Windows程序";
LabellblShow=newLabel();
lblShow.Location=newPoint(20,30);
lblShow.AutoSize=true;
lblShow.Text="王蕾!
";
this.Controls.Add(lblShow);
3、编写一个一个程序,用来判断输入的是大写字母,小写字母,数字还是其他的字符。
namespaceone.third
Console.WriteLine("请输入一个字符:
charc=Convert.ToChar(Console.ReadLine());
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
Console.WriteLine("这是一个字母");
if(char.IsDigit(c))
Console.WriteLine("这是一个数字");
4、分别用while,do-while,for循环求1到100的和。
namespaceone.forth.one
inti=1,sum=0;
while(i<=100)
sum=sum+i;
i++;
Console.WriteLine("1到100的自然数之和为:
"+sum);
namespaceone.forth.two
do
while(i<=100);
Console.WriteLine("1到100的自然数的和为:
namespaceone.forth.three
inti,sum=0;
for(i=1;i<=100;i++)
5、定义一个一维数组,用随机数为此赋值,用foreach循环输出其中的内容。
namespacefirst.five
int[]a={0,1,2,3,4};
foreach(intiina)
Console.WriteLine(a[i]);
6、实现二维数组的输入和输出。
namespacefirst.six
int[,]a=newint[2,3]{{1,2,3},{4,5,6}};
for(inti=0;i<2;i++)
for(intj=0;j<3;j++)
{Console.WriteLine(a[i,j]);}
7、实现数组型数组的输入和输出。
namespacefirst.seven
int[][]a=newint[][]{newint[]{1,2,3},newint[]{4,5,6}};
for(inti=0;i{for(intj=0;j{Console.WriteLine(a[i][j]);}}}}}六、实验体会(遇到问题及解决办法,编程后的心得体会)刚开始编程的时候觉得无从下手,尽管我们已经学了好几种高级编程语言,但每个都有其独特的地方,稍不留神就会混淆。通过这次实验,我体会到课后复习巩固的重要性。在编程的时候,很多内容都不记得,需要去翻书。不得不说,实验是巩固课程的好方法!本次实验,我熟悉VisualStudio.NET开发环境;掌握了C#应用程序的基本操作过程;掌握了C#的数据类型,运算符以及表达式的使用;掌握了分支和循环语句的使用方法以及一维数组,二维数组及数组型数组的使用。实验项目名称:类与对象实验学时:6同组学生姓名:实验地点:1318实验日期:10月26日-11月9日实验成绩:批改教师:批改时间:实验2类与对象一、实验目的、要求(1)掌握类的定义和使用;(2)掌握类的数据成员,属性的定义和使用;(3)掌握方法的定义,调用和重载以及方法参数的传递;(4)掌握构造函数的定义和使用。二、实验要求(1)编写程序要规范、正确,上机调试过程和结果要有记录;(2)做完实验后给出本实验的实验报告。三、实验设备、环境安装有VisualStudio.NET软件。四、实验步骤1、分析题意;2、根据题目要求,新建项目;3、编写并输入相关的程序代码;5、运行与调试项目;6、保存项目。五、实验内容1、定义一个方法,实现两个数的交换(分别把参数按值传递和按引用传递)。usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacesecond.one{classProgram{staticvoidMain(string[]args){Swapers=newSwaper();Console.WriteLine("输入x的值:");inta=Convert.ToInt32(Console.ReadLine());Console.WriteLine("输入y的值:");intb=Convert.ToInt32(Console.ReadLine());Console.WriteLine(s.Swap(a,b));Console.WriteLine(s.Swap(refa,refb));}classSwaper{publicstringSwap(intx,inty){inttemp;temp=x;x=y;y=temp;returnstring.Format("按值传参交换之后:x={0},y={1}",x,y);}publicstringSwap(refintx,refinty){inttemp;temp=x;x=y;y=temp;returnstring.Format("按引用传参交换之后:x={0},y={1}",x,y);}}}}2、定义一个方法,实现数组的排序。usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacesecond.two{classProgram{publicclasssort{publicvoidchange(int[]a){Console.WriteLine("排序前,数组顺序为:");show(a);inti,j,m;for(i=0;i<10;i++){m=a[i];j=i-1;//a[j]为数组前一个值while(j>=0&&m>a[j])//判断i下标的数是否大于j下标的数{a[j+1]=a[j];//如果i下标大于j把j往后移一个位j--;}a[j+1]=m;//当不大于j的时候就把M的值放到i下标下面j+1是为了下标减到最前时考虑-1+1还是下标的最前面}Console.WriteLine("排序后,数组顺序为:");show(a);}voidshow(int[]a){inti;for(i=0;i<10;i++){Console.Write("{0}",a[i]);}Console.WriteLine();}}staticvoidMain(string[]args){int[]a={4,7,1,2,5,8,9,10,3,6};sorts=newsort();s.change(a);}}}3、定义一个学生类,把学生类当作对象来传递。usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacesecond.three{classProgram{publicclassstudent{publicvoidst(){inta=999;}}publicclassst{publicvoidaa(students){Console.WriteLine(s);}}staticvoidMain(string[]args){students=newstudent();sts1=newst();s1.aa(s);}}}4、定义一个方法,求两个数的和和差,通过参数把这两个值带回。usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacesecond.four{classProgram{publicclasssum{publicvoidab(outintm,outintn,inta,intb){m=a+b;n=a-b;}}staticvoidMain(string[]args){sums=newsum();inta=10;intb=3;intm,n;s.ab(outm,outn,a,b);Console.WriteLine("{0}+{1}={2};{0}-{1}={3}",a,b,m,n);}}}5、用构造函数重载,实现矩形的面积,圆的面积,梯形的面积;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacesecong.five{classProgram{publicclasssquare{publicdoublearea;publicsquare(){}publicsquare(doublea){area=a*a*3.14;}publicsquare(doublea,doubleb){area=a*b;}publicsquare(doublea,doubleb,doubleh){area=(a+b)/2*h;}}staticvoidMain(string[]args){doublea,b,h,area;a=2;b=5;h=3;squares=newsquare(a,b);Console.WriteLine("求矩形面积,长为a={0},宽为b={1},面积area={2}",a,b,s.area);squarei=newsquare(a);Console.WriteLine("求圆形面积,半径a={0},面积area={1}",a,i.area);squarej=newsquare(a,b,h);Console.WriteLine("求梯形面积,上底为a={0},下底为b={1},高为h={2}面积area={3}",a,b,h,j.area);}}}6、设计一个windows应用程序,在该程序中定义一个学生类和班级类,以处理每个学生的学号,姓名,语文,数学和英语成绩,要求:1)能查询每个学生的总成绩。2)能显示全班前三名的名单。3)能显示单科成绩最高分和不及格的学生名单。4)能统计全班学生的平均成绩。5)能显示各科成绩不同分数段的学生人数的百分比。Student类:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceTest2_6{publicclassStudent{publicstringstuNo;publicstringname;publicdoublechinese;publicdoublemath;publicdoubleenglish;publicdoublesumScore{get{returnchinese+math+english;}}}}StudentList类:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceTest2_6{publicclassStudentList:Student{intsnums;publicStudent[]stu=newStudent[50];publicStudentList(){snums=0;}publicvoidaddstu(Students){stu[snums]=s;snums++;}publicintsearchstu(stringname){inti;for(i=0;i{if(stu[i].name==name)break;}if(i==snums)return-1;elsereturni;}//给所有成绩排序,用后面实现前三名的排名publicvoidProThree(){for(inti=0;i{intk=i;for(intj=i+1;jif(stu[j].sumScore>stu[k].sumScore)k=j;if(k!=i){Studenttemp;temp=stu[k];stu[k]=stu[i];stu[i]=temp;}}}//显示单科成绩的最高分publicintHighScore(intk){intp=0;if(k==0){for(inti=1;iif(stu[i].math>stu[p].math)p=i;}elseif(k==1){for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
for(intj=0;j{Console.WriteLine(a[i][j]);}}}}}六、实验体会(遇到问题及解决办法,编程后的心得体会)刚开始编程的时候觉得无从下手,尽管我们已经学了好几种高级编程语言,但每个都有其独特的地方,稍不留神就会混淆。通过这次实验,我体会到课后复习巩固的重要性。在编程的时候,很多内容都不记得,需要去翻书。不得不说,实验是巩固课程的好方法!本次实验,我熟悉VisualStudio.NET开发环境;掌握了C#应用程序的基本操作过程;掌握了C#的数据类型,运算符以及表达式的使用;掌握了分支和循环语句的使用方法以及一维数组,二维数组及数组型数组的使用。实验项目名称:类与对象实验学时:6同组学生姓名:实验地点:1318实验日期:10月26日-11月9日实验成绩:批改教师:批改时间:实验2类与对象一、实验目的、要求(1)掌握类的定义和使用;(2)掌握类的数据成员,属性的定义和使用;(3)掌握方法的定义,调用和重载以及方法参数的传递;(4)掌握构造函数的定义和使用。二、实验要求(1)编写程序要规范、正确,上机调试过程和结果要有记录;(2)做完实验后给出本实验的实验报告。三、实验设备、环境安装有VisualStudio.NET软件。四、实验步骤1、分析题意;2、根据题目要求,新建项目;3、编写并输入相关的程序代码;5、运行与调试项目;6、保存项目。五、实验内容1、定义一个方法,实现两个数的交换(分别把参数按值传递和按引用传递)。usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacesecond.one{classProgram{staticvoidMain(string[]args){Swapers=newSwaper();Console.WriteLine("输入x的值:");inta=Convert.ToInt32(Console.ReadLine());Console.WriteLine("输入y的值:");intb=Convert.ToInt32(Console.ReadLine());Console.WriteLine(s.Swap(a,b));Console.WriteLine(s.Swap(refa,refb));}classSwaper{publicstringSwap(intx,inty){inttemp;temp=x;x=y;y=temp;returnstring.Format("按值传参交换之后:x={0},y={1}",x,y);}publicstringSwap(refintx,refinty){inttemp;temp=x;x=y;y=temp;returnstring.Format("按引用传参交换之后:x={0},y={1}",x,y);}}}}2、定义一个方法,实现数组的排序。usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacesecond.two{classProgram{publicclasssort{publicvoidchange(int[]a){Console.WriteLine("排序前,数组顺序为:");show(a);inti,j,m;for(i=0;i<10;i++){m=a[i];j=i-1;//a[j]为数组前一个值while(j>=0&&m>a[j])//判断i下标的数是否大于j下标的数{a[j+1]=a[j];//如果i下标大于j把j往后移一个位j--;}a[j+1]=m;//当不大于j的时候就把M的值放到i下标下面j+1是为了下标减到最前时考虑-1+1还是下标的最前面}Console.WriteLine("排序后,数组顺序为:");show(a);}voidshow(int[]a){inti;for(i=0;i<10;i++){Console.Write("{0}",a[i]);}Console.WriteLine();}}staticvoidMain(string[]args){int[]a={4,7,1,2,5,8,9,10,3,6};sorts=newsort();s.change(a);}}}3、定义一个学生类,把学生类当作对象来传递。usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacesecond.three{classProgram{publicclassstudent{publicvoidst(){inta=999;}}publicclassst{publicvoidaa(students){Console.WriteLine(s);}}staticvoidMain(string[]args){students=newstudent();sts1=newst();s1.aa(s);}}}4、定义一个方法,求两个数的和和差,通过参数把这两个值带回。usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacesecond.four{classProgram{publicclasssum{publicvoidab(outintm,outintn,inta,intb){m=a+b;n=a-b;}}staticvoidMain(string[]args){sums=newsum();inta=10;intb=3;intm,n;s.ab(outm,outn,a,b);Console.WriteLine("{0}+{1}={2};{0}-{1}={3}",a,b,m,n);}}}5、用构造函数重载,实现矩形的面积,圆的面积,梯形的面积;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacesecong.five{classProgram{publicclasssquare{publicdoublearea;publicsquare(){}publicsquare(doublea){area=a*a*3.14;}publicsquare(doublea,doubleb){area=a*b;}publicsquare(doublea,doubleb,doubleh){area=(a+b)/2*h;}}staticvoidMain(string[]args){doublea,b,h,area;a=2;b=5;h=3;squares=newsquare(a,b);Console.WriteLine("求矩形面积,长为a={0},宽为b={1},面积area={2}",a,b,s.area);squarei=newsquare(a);Console.WriteLine("求圆形面积,半径a={0},面积area={1}",a,i.area);squarej=newsquare(a,b,h);Console.WriteLine("求梯形面积,上底为a={0},下底为b={1},高为h={2}面积area={3}",a,b,h,j.area);}}}6、设计一个windows应用程序,在该程序中定义一个学生类和班级类,以处理每个学生的学号,姓名,语文,数学和英语成绩,要求:1)能查询每个学生的总成绩。2)能显示全班前三名的名单。3)能显示单科成绩最高分和不及格的学生名单。4)能统计全班学生的平均成绩。5)能显示各科成绩不同分数段的学生人数的百分比。Student类:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceTest2_6{publicclassStudent{publicstringstuNo;publicstringname;publicdoublechinese;publicdoublemath;publicdoubleenglish;publicdoublesumScore{get{returnchinese+math+english;}}}}StudentList类:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceTest2_6{publicclassStudentList:Student{intsnums;publicStudent[]stu=newStudent[50];publicStudentList(){snums=0;}publicvoidaddstu(Students){stu[snums]=s;snums++;}publicintsearchstu(stringname){inti;for(i=0;i{if(stu[i].name==name)break;}if(i==snums)return-1;elsereturni;}//给所有成绩排序,用后面实现前三名的排名publicvoidProThree(){for(inti=0;i{intk=i;for(intj=i+1;jif(stu[j].sumScore>stu[k].sumScore)k=j;if(k!=i){Studenttemp;temp=stu[k];stu[k]=stu[i];stu[i]=temp;}}}//显示单科成绩的最高分publicintHighScore(intk){intp=0;if(k==0){for(inti=1;iif(stu[i].math>stu[p].math)p=i;}elseif(k==1){for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
Console.WriteLine(a[i][j]);
六、实验体会(遇到问题及解决办法,编程后的心得体会)
刚开始编程的时候觉得无从下手,尽管我们已经学了好几种高级编程语言,但每个都有其独特的地方,稍不留神就会混淆。
通过这次实验,我体会到课后复习巩固的重要性。
在编程的时候,很多内容都不记得,需要去翻书。
不得不说,实验是巩固课程的好方法!
本次实验,我熟悉VisualStudio.NET开发环境;掌握了C#应用程序的基本操作过程;掌握了C#的数据类型,运算符以及表达式的使用;掌握了分支和循环语句的使用方法以及一维数组,二维数组及数组型数组的使用。
类与对象实验学时:
10月26日-11月9日实验成绩:
实验2类与对象
一、实验目的、要求
(1)掌握类的定义和使用;
(2)掌握类的数据成员,属性的定义和使用;
(3)掌握方法的定义,调用和重载以及方法参数的传递;
(4)掌握构造函数的定义和使用。
(1)编写程序要规范、正确,上机调试过程和结果要有记录;
1、分析题意;
2、根据题目要求,新建项目;
3、编写并输入相关的程序代码;
5、运行与调试项目;
1、定义一个方法,实现两个数的交换(分别把参数按值传递和按引用传递)。
namespacesecond.one
Swapers=newSwaper();
Console.WriteLine("输入x的值:
inta=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("输入y的值:
intb=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(s.Swap(a,b));
Console.WriteLine(s.Swap(refa,refb));
classSwaper
publicstringSwap(intx,inty)
inttemp;
temp=x;
x=y;
y=temp;
returnstring.Format("按值传参交换之后:
x={0},y={1}",x,y);
publicstringSwap(refintx,refinty)
returnstring.Format("按引用传参交换之后:
}2、定义一个方法,实现数组的排序。
namespacesecond.two
publicclasssort
publicvoidchange(int[]a)
Console.WriteLine("排序前,数组顺序为:
show(a);
inti,j,m;
for(i=0;i<10;i++)
m=a[i];
j=i-1;//a[j]为数组前一个值
while(j>=0&&m>a[j])//判断i下标的数是否大于j下标的数
a[j+1]=a[j];//如果i下标大于j把j往后移一个位
j--;
a[j+1]=m;//当不大于j的时候就把M的值放到i下标下面j+1是为了下标减到最前时考虑-1+1还是下标的最前面
Console.WriteLine("排序后,数组顺序为:
voidshow(int[]a)
inti;
Console.Write("{0}",a[i]);
Console.WriteLine();
int[]a={4,7,1,2,5,8,9,10,3,6};
sorts=newsort();
s.change(a);
3、定义一个学生类,把学生类当作对象来传递。
namespacesecond.three
publicclassstudent
publicvoidst()
inta=999;
publicclassst
publicvoidaa(students)
Console.WriteLine(s);
students=newstudent();
sts1=newst();
s1.aa(s);
4、定义一个方法,求两个数的和和差,通过参数把这两个值带回。
namespacesecond.four
publicclasssum
publicvoidab(outintm,outintn,inta,intb)
m=a+b;
n=a-b;
sums=newsum();
inta=10;
intb=3;
intm,n;
s.ab(outm,outn,a,b);
Console.WriteLine("{0}+{1}={2};{0}-{1}={3}",a,b,m,n);
5、用构造函数重载,实现矩形的面积,圆的面积,梯形的面积;
namespacesecong.five
publicclasssquare
publicdoublearea;
publicsquare(){}
publicsquare(doublea)
area=a*a*3.14;
publicsquare(doublea,doubleb)
area=a*b;
publicsquare(doublea,doubleb,doubleh)
area=(a+b)/2*h;
doublea,b,h,area;
a=2;b=5;h=3;
squares=newsquare(a,b);
Console.WriteLine("求矩形面积,长为a={0},宽为b={1},面积area={2}",a,b,s.area);
squarei=newsquare(a);
Console.WriteLine("求圆形面积,半径a={0},面积area={1}",a,i.area);
squarej=newsquare(a,b,h);
Console.WriteLine("求梯形面积,上底为a={0},下底为b={1},高为h={2}面积area={3}",a,b,h,j.area);
6、设计一个windows应用程序,在该程序中定义一个学生类和班级类,以处理每个学生的学号,姓名,语文,数学和英语成绩,要求:
1)能查询每个学生的总成绩。
2)能显示全班前三名的名单。
3)能显示单科成绩最高分和不及格的学生名单。
4)能统计全班学生的平均成绩。
5)能显示各科成绩不同分数段的学生人数的百分比。
Student类:
namespaceTest2_6
publicclassStudent
publicstringstuNo;
publicstringname;
publicdoublechinese;
publicdoublemath;
publicdoubleenglish;
publicdoublesumScore
get{returnchinese+math+english;}
StudentList类:
publicclassStudentList:
Student
intsnums;
publicStudent[]stu=newStudent[50];
publicStudentList()
snums=0;
publicvoidaddstu(Students)
stu[snums]=s;
snums++;
publicintsearchstu(stringname)
for(i=0;i{if(stu[i].name==name)break;}if(i==snums)return-1;elsereturni;}//给所有成绩排序,用后面实现前三名的排名publicvoidProThree(){for(inti=0;i{intk=i;for(intj=i+1;jif(stu[j].sumScore>stu[k].sumScore)k=j;if(k!=i){Studenttemp;temp=stu[k];stu[k]=stu[i];stu[i]=temp;}}}//显示单科成绩的最高分publicintHighScore(intk){intp=0;if(k==0){for(inti=1;iif(stu[i].math>stu[p].math)p=i;}elseif(k==1){for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
if(stu[i].name==name)break;
if(i==snums)return-1;
elsereturni;
//给所有成绩排序,用后面实现前三名的排名
publicvoidProThree()
for(inti=0;i{intk=i;for(intj=i+1;jif(stu[j].sumScore>stu[k].sumScore)k=j;if(k!=i){Studenttemp;temp=stu[k];stu[k]=stu[i];stu[i]=temp;}}}//显示单科成绩的最高分publicintHighScore(intk){intp=0;if(k==0){for(inti=1;iif(stu[i].math>stu[p].math)p=i;}elseif(k==1){for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
intk=i;
for(intj=i+1;jif(stu[j].sumScore>stu[k].sumScore)k=j;if(k!=i){Studenttemp;temp=stu[k];stu[k]=stu[i];stu[i]=temp;}}}//显示单科成绩的最高分publicintHighScore(intk){intp=0;if(k==0){for(inti=1;iif(stu[i].math>stu[p].math)p=i;}elseif(k==1){for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
if(stu[j].sumScore>stu[k].sumScore)k=j;
if(k!
=i)
Studenttemp;
temp=stu[k];
stu[k]=stu[i];
stu[i]=temp;
//显示单科成绩的最高分
publicintHighScore(intk)
intp=0;
if(k==0)
for(inti=1;iif(stu[i].math>stu[p].math)p=i;}elseif(k==1){for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
if(stu[i].math>stu[p].math)p=i;
elseif(k==1)
for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}else{for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
if(stu[i].chinese>stu[p].chinese)p=i;
else
for(inti=1;iif(stu[i].chinese>stu[p].chinese)p=i;}returnp;}//显示不及格名单publicstringBuhgName(intk){stringname="";if(k==0){for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
returnp;
//显示不及格名单
publicstringBuhgName(intk)
stringname="";
for(inti=0;iif(stu[i].math<60)name+=stu[i].name+"\n";}elseif(k==1){for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
if(stu[i].math<60)name+=stu[i].name+"\n";
for(inti=0;iif(stu[i].chinese<60)name+=stu[i].name+"\n";
if(stu[i].chinese<60)name+=stu[i].name+"\n";
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1