第 1 頁:填空題 |
第 2 頁:改錯題 |
第 3 頁:程序題 |
注意: 不要改動main函數(shù), 不得增行或刪行, 也不得更改程序的結(jié)構(gòu)!
給定源程序:
#include
#include
#include
#define N 10
typedef struct ss
{char num[10];
int s;
} STU;
STU *fun(STU a[], int m)
{STU b[N], *t;
int i,j,k;
/**********found**********/
t=(STU *)calloc(sizeof(STU),m)
for(i=0; i for(k=0; k {for(i=j=0; i if(b[i].s > b[j].s) j=i; /**********found**********/ t(k)=b(j); b[j].s=0; } return t; } outresult(STU a[], FILE *pf) {int i; for(i=0; i fprintf(pf,"No = %s Mark = %d\n", a[i].num,a[i].s); fprintf(pf,"\n\n"); } main() {STU a[N]={ {"A01",81},{"A02",89},{"A03",66}, {"A04",87},{"A05",77},{"A06",90},{"A07",79},{"A08",61},{"A09",80},{"A10",71} }; STU *pOrder; int i, m; printf("***** The Original data *****\n"); outresult(a, stdout); printf("\nGive the number of the students who have better score: "); scanf("%d",&m); while(m>10) {printf("\nGive the number of the students who have better score: "); scanf("%d",&m); } pOrder=fun(a,m); printf("***** THE RESULT *****\n"); printf("The top :\n"); for(i=0; i printf(" %s %d\n",pOrder[i].num , pOrder[i].s); free(pOrder); } 解題答案: /**********found**********/ t=(STU *)calloc(sizeof(STU),m); /**********found**********/ t[k]=b[j]; ****************************************** 2011年計(jì)算機(jī)等級考試二級C語言上機(jī)題庫
北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內(nèi)蒙古 |