1 条题解
-
0
C :
#include<stdio.h> #include<string.h> int main() { int xue[4],a[4][5],i,k; double s=0,w=0,x[4]={0},y[4]={0}; for(i=0;i<4;i++) { scanf("%d",&xue[i]); for(k=0;k<5;k++) { scanf("%d",&a[i][k]); } } for(i=0;i<4;i++) { s += a[i][0]; } s=s/4.; printf("%.2lf\n",s); for(i=0;i<4;i++) {s=0; for(k=0;k<5;k++) { if(a[i][k]<60) s++; } for(k=0;k<5;k++) { if(a[i][k]>=85) x[i]++; else break; } if(s>=2) { printf("%d ",xue[i]); for(k=0;k<5;k++) { printf("%d ",a[i][k]); w+=a[i][k]; } w=w/5; printf("%.2lf\n",w); } for(k=0;k<5;k++) { y[i]+=a[i][k]; } y[i]=y[i]/5; } for(i=0;i<4;i++) { if(x[i]==5) printf("%d ",xue[i]); else if(y[i]>=90) printf("%d ",xue[i]); } printf("\n"); return 0; }
C++ :
#include <stdio.h> int main() { void request1(int id[], int score[][5], int n); void request2(int id[], int score[][5], int n); void request3(int id[], int score[][5], int n); int id[4], score[4][5]; int i, j; for (i = 0;i < 4;i++) { scanf("%d", &id[i]); for (j = 0;j < 5;j++) scanf("%d", &score[i][j]); } request1(id, score, 4); request2(id, score, 4); request3(id, score, 4); return 0; } /* 第一个要求 */ void request1(int id[], int score[][5], int n) { int i; float total_score, aveg_score; total_score = 0; for (i = 0;i < n;i++) total_score += score[i][0]; aveg_score = total_score / n; printf("%.2f\n", aveg_score); } /* 第二个要求 */ void request2(int id[], int score[][5], int n) { int i, j, less_than_60; float total_score, aveg_score; for (i = 0;i < n;i++) { /* 统计该学生有多少门不及格 */ less_than_60 = 0; for (j = 0;j < 5;j++) if (score[i][j] < 60) less_than_60++; if (less_than_60 >= 2) { printf("%d ", id[i]); total_score = 0; for (j = 0;j < 5;j++) { printf("%d ", score[i][j]); total_score += score[i][j]; } aveg_score = total_score / 5; printf("%.2f\n", aveg_score); } } } /* 第三个要求 */ void request3(int id[], int score[][5], int n) { int i, j, not_less_than_85; float total_score, aveg_score, eps = 1e-5; for (i = 0;i < n;i++) { total_score = 0; not_less_than_85 = 0; /* 统计该学生有多少门在85分(含)以上,并计算平均分 */ for (j = 0;j < 5;j++) { if (score[i][j] >= 85) not_less_than_85++; total_score += score[i][j]; } aveg_score = total_score / 5; /* 这里的eps的作用是保证实数大小比较的准确性 */ if (not_less_than_85 == 5 || aveg_score >= 90 - eps) printf("%d ", id[i]); } printf("\n"); }
Pascal :
Program TK1296; var a:array[1..4]of record t,no:longint; x:real; f:array[1..5]of longint; end; c1:real; k,i,j:longint; Begin for i:=1 to 4 do with a[i] do begin read(no); for j:=1 to 5 do begin read(f[j]); x:=x+f[j]; if f[j]<60 then inc(t); end; x:=x/5; end; for i:=1 to 4 do c1:=c1+a[i].f[1]; c1:=c1/4; writeln(c1:0:2); for i:=1 to 4 do with a[i] do if t>=2 then begin write(no,' '); for j:=1 to 5 do write(f[j],' '); writeln(x:0:2); end; for i:=1 to 4 do with a[i] do begin if x>=90 then begin write(no,' '); continue; end; k:=0; for j:=1 to 5 do if f[j]<85 then k:=1; if k=0 then write(no,' '); end; writeln; End.
- 1
信息
- ID
- 1371
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者