第 1 頁:填空題 |
第 2 頁:改錯題 |
第 3 頁:程序題 |
一、填空題:給定程序中,函數fun的功能是:將形參指針所指結構體數組中的三個元素按num成員進行升序排列。請在程序的下劃線處填入正確的內容并把下劃線刪除,使程序得出正確的結果。
注意:源程序存放在考生文件夾的BLANK1.C中。
不得增行或刪行,也不得更改程序的結構!
給定源程序:
#include
typedef struct
{int num;
char name[10];
}PERSON;
/**********found**********/
void fun(PERSON ___1___)
{
/**********found**********/
___2___ temp;
if(std[0].num>std[1].num)
{temp=std[0]; std[0]=std[1]; std[1]=temp;}
if(std[0].num>std[2].num)
{temp=std[0]; std[0]=std[2]; std[2]=temp;}
if(std[1].num>std[2].num)
{temp=std[1]; std[1]=std[2]; std[2]=temp;}
}
main()
{PERSON std[]={ 5,"Zhanghu",2,"WangLi",6,"LinMin" };
int i;
/**********found**********/
fun(___3___);
printf("\nThe result is :\n");
for(i=0; i<3; i++)
printf("%d,%s\n",std[i].num,std[i].name);
}
解題答案:
/**********第一空**********/
void fun(PERSON *std)
/**********第二空**********/
PERSON temp;
/**********第三空**********/
fun(std);
******************************************
北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內蒙古 |