A是先取函數(shù)f返回的內存單元(參數(shù)是i即i的地址)中存儲的值,并作更改(改為6)
從事西部信息機房,服務器租用,云主機,網(wǎng)站空間,國際域名空間,CDN,網(wǎng)絡代維等服務。
B項 i+6 是算術表達式,不能直接取地址,必須使用變量保存才能取地址
C項 是定義一個指向整型的指針p,并賦值為函數(shù)f的返回值(該函數(shù)返回一個指針,也就是內存地址)
D項 直接以i為參數(shù)執(zhí)行函數(shù)f,返回值不起任何作用
#include?stdio.h
#define?STUDENTNUM?10
/*?由于學號只有9個數(shù)字,一個long型的整數(shù)就可以表示?*/
/*?成績只是0~100之間,一個char就可以表示了?*/
struct?student
{
long?xh;
char?dxyy;
char?cyycxsj;
char?jsjdl;
}?students[STUDENTNUM];
int?ResearchStu(long?xh);
/*?從文件讀取學生成績,如果文件不存在,需要手工輸入成績?*/
/*??成績數(shù)值必須在0~100之間。*/
void?init()
{
int?i,?tmp,?err;
FILE?*?fp?=?fopen("cj.dat",?"rb");
if(fp)?fread(students,?STUDENTNUM,?sizeof(struct?student),?fp);
else
{
for(i=0;?iSTUDENTNUM;?i++)
{
err?=?0;
printf("請輸入學號:");
scanf("%ld",?students[i].xh);
printf("請輸入大學英語成績:");
scanf("%d",?tmp);
if(0?=?tmp??tmp?=?100)?students[i].dxyy?=?(char)tmp;
else?err?=?1;
printf("請輸入C語言程序設計成績:");
scanf("%d",?tmp);
if(0?=?tmp??tmp?=?100)?students[i].cyycxsj?=?(char)tmp;
else?err?=?1;
printf("請輸入計算機導論成績:");
scanf("%d",?tmp);
if(0?=?tmp??tmp?=?100)?students[i].cyycxsj?=?(char)tmp;
else?err?=?1;
if(err)
{
printf("成績輸入錯誤,需要重新輸入!\n");
i--;
}
}
}
}
void?main()
{
long?xh,?pos;
init();
scanf("%ld",?xh);
pos?=?ResearchStu(xh);
if(pos?==?-1)?printf("查無此人!");
else
{
printf("%d\t大學英語\t%d分\n",?students[pos].xh,?students[pos].dxyy);
printf("%d\tC語言程序設計\t%d分\n",?students[pos].xh,?students[pos].cyycxsj);
printf("%d\t計算機導論\t%d分\n",?students[pos].xh,?students[pos].jsjdl);
}
}
int?ResearchStu(long?xh)
{
int?i;
for(i=0;?iSTUDENTNUM;?i++)?if(students[i].xh?==?xh)?return?i;
return?-1;
}
else if (x=0) y=0;
改為x==0
x=0 是賦值 語句 賦值完之后 x=0 ...if(x=0)==等價于 if(0);
本文名稱:c語言調用函數(shù)題目 c語言調用函數(shù)例題
瀏覽地址:http://jinyejixie.com/article22/hpdejc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站排名、品牌網(wǎng)站制作、虛擬主機、網(wǎng)站策劃、網(wǎng)頁設計公司
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)