首页 > 代码库 > Pascal学生管理
Pascal学生管理
1 program Project2; 2 3 {$APPTYPE CONSOLE} 4 5 uses 6 SysUtils; 7 8 const N=2;M=3; 9 type 10 11 date=record 12 day:1..31; 13 month:1..12; 14 year:1970..1999; 15 end; 16 student=record 17 number:string[5]; 18 name:string[8]; 19 birthday:date; 20 score:array[1..M]of real; 21 average:real; 22 end; 23 var 24 stu:array[1..N] of student; 25 counter,s,i,j,k:integer; 26 t:real; 27 a:student; 28 temp:student; 29 ch:string[8]; 30 begin 31 { TODO -oUser -cConsole Main : Insert code here } 32 for k:=1 to N do 33 begin 34 with a,birthday do 35 begin 36 write(k:2,‘number:‘);readln(number); 37 write(k:2,‘name:‘);readln(name); 38 write(k:2,‘day:‘);readln(day); 39 write(k:2,‘month:‘);readln(month); 40 write(k:2,‘year:‘);readln(year); 41 t:=0; 42 for i:= 1 to M do 43 begin 44 write(‘score[‘,i,‘]=‘);read(a.score[i]); 45 t:=t+a.score[i] 46 end; 47 readln; 48 stu[k]:=a; 49 stu[k].average:=t/M; 50 end; 51 end; 52 for j:=1 to N do 53 for k:=1 to N-j do 54 if stu[k].average<stu[k+1].average then 55 begin 56 temp:=stu[k]; 57 stu[j]:=stu[k+1]; 58 stu[k+1]:=temp; 59 end; 60 Writeln(‘按平均分从高到低排‘); 61 writeln(‘----------------------------------------------------------‘); 62 write(‘num‘,‘‘:5,‘name‘,‘‘:9,‘mm/dd/yy‘:10,‘‘:4); 63 writeln(‘chinese‘,‘‘:2,‘math‘,‘‘:2,‘english‘,‘‘:2,‘average‘); 64 writeln(‘-----------------------------------------------------------‘); 65 for j:=1 to N do 66 with stu[j],birthday do 67 begin 68 write(number:5,name:9,‘‘:8,month:2,‘/‘,day:2,‘/‘,year:4,‘ ‘); 69 for i:= 1to M do write(score[i]:6:1); 70 writeln(stu[j].average:10:1) 71 72 end; 73 for j:=1 to N do 74 for k:=1 to N-j do 75 if (stu[k].name)>(stu[k+1].name) then 76 begin 77 temp:=stu[k]; 78 stu[j]:=stu[k+1]; 79 stu[k+1]:=temp; 80 end; 81 Writeln(‘按学生姓名的字典顺序排‘); 82 writeln(‘----------------------------------------------------------‘); 83 write(‘num‘,‘‘:5,‘name‘,‘‘:9,‘mm/dd/yy‘:10,‘‘:4); 84 writeln(‘chinese‘,‘‘:2,‘math‘,‘‘:2,‘english‘,‘‘:2,‘average‘); 85 writeln(‘-----------------------------------------------------------‘); 86 for j:=1 to N do 87 with stu[j],birthday do 88 begin 89 write(number:5,name:9,‘‘:8,month:2,‘/‘,day:2,‘/‘,year:4,‘ ‘); 90 for i:= 1to M do write(score[i]:6:1); 91 writeln(stu[j].average:10:1) 92 93 end; 94 writeln(‘按姓名查找学生信息‘); 95 readln(ch); 96 s:=0; 97 for j:=1 to N do 98 if (stu[j].name)=ch then 99 begin 100 writeln(‘----------------------------------------------------------‘); 101 write(‘num‘,‘‘:5,‘name‘,‘‘:9,‘mm/dd/yy‘:10,‘‘:4); 102 writeln(‘chinese‘,‘‘:2,‘math‘,‘‘:2,‘english‘,‘‘:2,‘average‘); 103 writeln(‘-----------------------------------------------------------‘); 104 with stu[j],birthday do 105 begin 106 write(number:5,name:9,‘‘:8,month:2,‘/‘,day:2,‘/‘,year:4,‘ ‘); 107 for i:= 1to M do write(score[i]:6:1); 108 writeln(stu[j].average:10:1) 109 end; 110 end else s:=s+1; 111 if s=N then Writeln(‘没有找到该学生信息‘); 112 writeln(‘将数学不及格的学生信息输出,并统计数学成绩不及格人数‘); 113 counter:=0; 114 for j:=1 to N do 115 if (stu[j].score[2])<60 then 116 begin 117 counter:=counter+1; 118 writeln(‘----------------------------------------------------------‘); 119 write(‘num‘,‘‘:5,‘name‘,‘‘:9,‘mm/dd/yy‘:10,‘‘:4); 120 writeln(‘chinese‘,‘‘:2,‘math‘,‘‘:2,‘english‘,‘‘:2,‘average‘); 121 writeln(‘-----------------------------------------------------------‘); 122 with stu[j],birthday do 123 begin 124 write(number:5,name:9,‘‘:8,month:2,‘/‘,day:2,‘/‘,year:4,‘ ‘); 125 for i:= 1to M do write(score[i]:6:1); 126 writeln(stu[j].average:10:1) 127 end; 128 end; 129 writeln(‘数学不及格人数:‘,counter); 130 readln; 131 end.
Pascal学生管理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。