1994年程序员考试-下午试题
【程 序】
#define MAXSCORE 20
#define QUESTION 10
#define ORDERS 5
main()
{ int p[QUESTION]={0,0,0,0,0,0,0,0,0,0},
n[QUESTION]={0,0,0,0,0,0,0,0,0,0},
s[QUESTION]={0,0,0,0,0,0,0,0,0,0};
int f[ORDERS]={0,0,0,0,0};
int i,score,c,number,pn=0;
char fig,ch[120];
char *title[]={" 90 -- 100 A",
" 80 -- 89 B",
" 70 -- 79 C",
" 60 -- 69 D",
" 0 -- 59 E"}
while(1)
{
printf("Enter number && score1 -- score10 ");
if (scanf("%d",&number) ==0)
{
gets(ch);
printf("Error! Input again!");
continue;
}
for (c=0,i=1;i<QUESTION && c== i; i++)
if (scanf("%d",&p[i]))
if (p[i] <= MAXSCORE)
_________________________ ;
if ( ______________________ )
{
gets(ch);
printf("Error! Input again!");
continue;
}
for (c=0,score=0,i=0;i<QUESTION;i++)
if ( _______________ )
{
c++; score +=p[i]; n[i]++; s[i] +=p[i];
}
fig = (score ==100) ? ’A’: (score < 60) ? _____________________;
f[ _______ ]++; pn++;
printf("Number = %d Score = %d Mark = %c",number,score,fig);
}
printf("STUDENTS = %d",pn);
for (i=0;i<ORDERS;i++) printf("%s%7d",title[i],f[i]);
printf(" Question Students Average");
for (i=0;i<QUESTION;i++)
if (n[i]) printf("%6d%10d%10.2f",i+1,n[i], _______________ );
else pritnf ("6d%10d%10s",i+1,n[i]," --");
}
本程序实现安照每页宽80列平均分左右两栏的格式
印出正文文件内容.
程序引入数组buff[] [] [] 和ln [] [], 将从文件
读出的字符按行存储于buff[0],行号存于ln[0](对应左栏
), 或buff[1],ln[1](对应右栏).约定,文件内容先填左栏
填满后,再填右栏.或左右两栏填满,或文件内容填完,输出
一页的内容.
欲输出的正文文件(小于1000行)的文件名作为主函数
的参数.主函数以文件名为参数调用函数dprint()输出一个
文件.函数dprint()读取文件内容,控制栏中的一行内容的
填写,当一行填满时,调用函数nextline().函数nextline()
控制栏中行的变化,左右栏的变化.待左右栏都填满时,调用
函数printout()完成整页输出.函数printout()完成页面排
版,取ln[0] buff[0]和ln[1] buff[1],将对应行号及内容
填入line[],逐行输出.
【程 序】
#include <stdio.h>
#define LL 80
#define COL 2
#define CSIZE LL/COL-9
#define PL 50
[1] [2] [3] 下一页 |
|
|
|