新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

c语言调用函数题目 c语言调用函数例题

C语言函数调用问题(选择题)

A是先取函数f返回的内存单元(参数是i即i的地址)中存储的值,并作更改(改为6)

从事西部信息机房,服务器租用,云主机,网站空间,国际域名空间,CDN,网络代维等服务。

B项 i+6 是算术表达式,不能直接取地址,必须使用变量保存才能取地址

C项 是定义一个指向整型的指针p,并赋值为函数f的返回值(该函数返回一个指针,也就是内存地址)

D项 直接以i为参数执行函数f,返回值不起任何作用

C语言设计函数和调用函数的题目

#include stdio.h

#define STUDENTNUM 10

/* 由于学号只有9个数字,一个long型的整数就可以表示 */

/* 成绩只是0~100之间,一个char就可以表示了 */

struct student

{

long xh;

char dxyy;

char cyycxsj;

char jsjdl;

} students[STUDENTNUM];

int ResearchStu(long xh);

/* 从文件读取学生成绩,如果文件不存在,需要手工输入成绩 */

/*  成绩数值必须在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;

}

C语言 调用函数

else if (x=0) y=0;

改为x==0

x=0 是赋值 语句 赋值完之后 x=0 ...if(x=0)==等价于 if(0);


分享名称:c语言调用函数题目 c语言调用函数例题
转载源于:http://www.wjwzjz.com/article/hpdejc.html
在线咨询
服务热线
服务热线:028-86922220
TOP