#include <stdio.h>
int main()
{ void input(int *)
void max_min_value(int *)
void output(int *)
int number[10]
input(number)
max_min_value(number)
output(number)
return 0
}
void input(int *number)
{int i
printf("input 10 numbers:")
for (i=0i<10i++)
scanf("%d",&number[i])
}
void max_min_value(int *number)
{ int *max,*min,*p,temp
max=min=number
for (p=number+1p<number+10p++)
if (*p>*max) max=p
else if (*p<*min) min=p
temp=number[0]number[0]=*min*min=temp
if(max==number) max=min
temp=number[9]number[9]=*max*max=temp
}
void output(int *number)
{int *p
printf("Now,they are:")
for (p=numberp<number+10p++)
printf("%d ",*p)
printf("\n")
}
//课后14
#include <stdio.h>
int main()
{void sort (char *p,int m)
int i,n
char *p,num[20]
printf("input n:")
scanf("%d",&n)
printf("please input these numbers:\n")
for (i=0i<ni++)
scanf("%d",&num[i])
p=&num[0]
sort(p,n)
printf("Now,the sequence is:\n")
for (i=0i<ni++)
printf("%d ",num[i])
printf("\n")
return 0
}
void sort (char *p,int m) // 将n个数逆序排列函数
{int i
char temp, *p1,*p2
for (i=0i<m/2i++)
{p1=p+i
p2=p+(m-1-i)
temp=*p1
*p1=*p2
*p2=temp
}
}
//课后15
#include <stdio.h>
int main()
{void avsco(float *,float *)
void avcour1(char (*)[10],float *)
void fali2(char course[5][10],int num[],float *pscore,float aver[4])
void good(char course[5][10],int num[4],float *pscore,float aver[4])
int i,j,*pnum,num[4]
float score[4][5],aver[4],*pscore,*paver
char course[5][10],(*pcourse)[10]
printf("input course:\n")
pcourse=course
for (i=0i<5i++)
scanf("%s",course[i])
printf("input NO. and scores:\n")
printf("NO.")
for (i=0i<5i++)
printf(",%s",course[i])
printf("\n")
pscore=&score[0][0]
pnum=&num[0]
for (i=0i<4i++)
{scanf("%d",pnum+i)
for (j=0j<5j++)
scanf("%f",pscore+5*i+j)
}
paver=&aver[0]
printf("\n\n")
avsco(pscore,paver) // 求出每个学生的平均成绩
avcour1(pcourse,pscore) // 求出第一门课的平均成绩
printf("\n\n")
fali2(pcourse,pnum,pscore,paver) // 找出2门课不及格的学生
printf("\n\n")
good(pcourse,pnum,pscore,paver) // 找出成绩好的学生
return 0
}
void avsco(float *pscore,float *paver) // 求每个学生的平均成绩的函数
{int i,j
float sum,average
for (i=0i<4i++)
{sum=0.0
for (j=0j<5j++)
sum=sum+(*(pscore+5*i+j)) //累计每个学生的各科成绩
average=sum/5 //计算平均成绩
*(paver+i)=average
}
}
void avcour1(char (*pcourse)[10],float *pscore) // 求第一课程的平均成绩的函数
{int i
float sum,average1
sum=0.0
for (i=0i<4i++)
sum=sum+(*(pscore+5*i)) //累计每个学生的得分
average1=sum/4 //计算平均成绩
printf("course 1:%s average score:%7.2f\n",*pcourse,average1)
}
void fali2(char course[5][10],int num[],float *pscore,float aver[4])
// 找两门以上课程不及格的学生的函数
{int i,j,k,labe1
printf("==========Student who is fail in two courses======= \n")
printf("NO. ")
for (i=0i<5i++)
printf("%11s",course[i])
printf("average\n")
for (i=0i<4i++)
{labe1=0
for (j=0j<5j++)
if (*(pscore+5*i+j)<60.0) labe1++
if (labe1>=2)
{printf("%d",num[i])
for (k=0k<5k++)
printf("%11.2f",*(pscore+5*i+k))
printf("%11.2f\n",aver[i])
}
}
}
void good(char course[5][10],int num[4],float *pscore,float aver[4])
// 找成绩优秀学生(各门85以上或平均90分以上)的函数
{int i,j,k,n
printf(" ======Students whose score is good======\n")
printf("NO. ")
for (i=0i<5i++)
printf("%11s",course[i])
printf("average\n")
for (i=0i<4i++)
{n=0
for (j=0j<5j++)
if (*(pscore+5*i+j)>85.0) n++
if ((n==5)||(aver[i]>=90))
{printf("%d",num[i])
for (k=0k<5k++)
printf("%11.2f",*(pscore+5*i+k))
printf("%11.2f\n",aver[i])
}
}
}
您要c语言程序设计教程第四版
课答案
(李丽娟).pdf我已发送请按照步骤进行 *** 作采纳我前进力记评采纳互相帮助c语言程序设计教程
第四版
课后答案
(李丽娟).pdf
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)