query.c
上传用户:bjtelijie
上传日期:2010-01-01
资源大小:87k
文件大小:1k
- /* 学生成绩查询系统 */
- # include <stdio.h>
- # include <stdlib.h>
- void main( )
- {
- int select;
- int i, j;
- int score[5][7];
- int average = 0;
- int sum = 0;
- do{
- printf("本程序有4项功能:n");
- printf(" 1. 根据学号查询学生成绩n");
- printf(" 2. 根据考试号统计成绩n") ;
- printf(" 3. 根据考试号和学号查询成绩n");
- printf(" 4. 成绩录入n");
- printf(" 0. 退出n");
- printf(" 请输入选择(0 - 4): ");
- scanf("%d", &select);
- switch(select)
- {
- case 0:
- printf("OKn");
- exit(0);
- break;
- case 1:
- printf("输入学号:");
- scanf("%dn", &i);
- for(j=1; j<7; j++)
- {
- printf("第%d科成绩是%dn", j, score[i][j]);
- sum += score[i][j];
- }
- average = sum/6;
- printf("学生的平均成绩是%dn", average);
- break;
- case 2:
- printf("输入考试号:");
- scanf("%dn", &j);
- for(i=1; i<5; i++)
- {
- printf("第%d号学生本科成绩是%dn", i, score[i][j]);
- sum += score[i][j];
- }
- average = sum/4;
- printf("本科平均成绩是%dn", average);
- break;
- case 3:
- printf("输入学号和考试号:");
- scanf("%d %dn", &i, &j);
- printf("第%d号学生的第%d科考试成绩是%dn", i, j, score[i][j]);
- break;
- case 4:
- printf("请输入成绩n");
- for(i=1; i<5; i++)
- for(j=1; j<7; j++)
- scanf("%dn", &score[i][j]);
- break;
- default:
- break;
- }
- }while(1);
- }