C语言 有a个学生,每个学生有b门课程的成绩。输入学生的序号后输出对应的全部成绩
Posted C语言大本营
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言 有a个学生,每个学生有b门课程的成绩。输入学生的序号后输出对应的全部成绩相关的知识,希望对你有一定的参考价值。
重点考察“返回指针值的函数”
#include <stdio.h>
float *search(float (*pointer)[4],int n) //形参pointer是指向一维数组的指针变量
float *pt; //pt的值是&score[k][0]
pt=*(pointer+n);
return pt;
int main()
float score[][4]=60,70,80,90,56,89,67,88,34,78,90,66;
float *p;
int i,k;
printf("enter the number of student:");
scanf("%d",&k);
printf("The scores of No.%d are:\\n",k);
p=search(score,k);
for(i=0;i<4;i++)
printf("%5.2f\\t",*(p+i));
return 0;
找出其中有不及格课程的学生及其学生号
#include <stdio.h>
float *search(float (*pointer)[4])
int i=0;
float *pt;
pt=NULL;
for(;i<4;i++)
if(*(*pointer+i)<60)
pt=*pointer;
return pt;
int main()
float score[][4]=60,70,80,90,56,89,67,88,34,78,90,66;
float *p;
int i,j;
for(i=0;i<3;i++)
p=search(score+i);
if(p==*(score+i))
printf("%d号学生不及格成绩为:",i);
for(j=0;j<4;j++)
printf("%6.2f",*(p+j));
printf("\\n");
return 0;
以上是关于C语言 有a个学生,每个学生有b门课程的成绩。输入学生的序号后输出对应的全部成绩的主要内容,如果未能解决你的问题,请参考以下文章