C语言程序设计导学(第三版)参考答案 杜友福 编

2026/1/20 5:47:27

(3)

#include void fun(char *pp) {

int i,k,n=0;

while(*(pp+n)=='*') n++;

for(i=n;*(pp+i)!='\\0';i++) if(*(pp+i)!='*') {

*(pp+n)=*(pp+i);

n++;

k=0; }

else k++; if(k!=0) {

for(i=1;i<=k;i++)

*(pp+n+i)='*'; *(pp+n+i)='\\0'; } else

*(pp+n)='\\0'; }

void main() {

char aa[80];

printf(\ scanf(\ fun(aa);

printf(\ printf(\}

实验十

2. 程序填空题

(*p) 、 struct stu 、 &student[2]

3. 程序改错题

}STREC;

if(a[i].sc

13

4. 程序设计题 (1)

#define N 10

#include typedef struct {

char num[10]; int sc; }STREC;

float fun(STREC a[],int n) {

int i,s=0; float ave;

for(i=0;i

s=s+a[i].sc;

ave=(float)s/n; return ave;

}

void main() {

int i;

float aver;

STREC s[N]={{\

{\{\{\

aver=fun(s,N); for(i=0;i

if(s[i].sc>aver)

printf(\

} (2)

#define N 10

#include typedef struct {

char num[10]; int sc; }STREC;

int fun(STREC a[],int n) {

int i,max=-1; for(i=0;imax)

14

max=a[i].sc; return max; }

void main() {

int i,maxsc;

STREC s[N]={{\

{\{\{\

maxsc=fun(s,N); for(i=0;i

if(s[i].sc==maxsc)

printf(\

} (3)

#include #define M 5 //人数 #define N 3 //课程数 struct student {

char num[10]; char name[20]; float score[N+1]; };

void main() {

struct student stud[M]; int i,j,max; float aver;

printf(\

printf(\ for(i=0;i

scanf(\

scanf(\

&stud[i].score[2]);

}

printf(\ for(j=0;j

aver=0;

for(i=0;i

aver=aver+stud[i].score[j];

15

aver=aver/M;

printf(\ }

max=0;

for(i=0;i

stud[i].score[3]=(stud[i].score[0]+stud[i].score[1]+

stud[i].score[2])/3;

printf(\

stud[i].name,stud[i].score[3]);

if(stud[i].score[3]>stud[max].score[3]) max=i; }

printf(\

printf(\

stud[max].num, stud[max].name,

stud[max].score[0],stud[max].score[1],

stud[max].score[2],stud[max].score[3]);

}

16


C语言程序设计导学(第三版)参考答案 杜友福 编.doc 将本文的Word文档下载到电脑
搜索更多关于: C语言程序设计导学(第三版)参考答案 杜友福 编 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219