程序1
#include<stdio.h>
int main()
{
float * search (float (* pointer)[4] , int n);
float score[][4]={{60,70,80,90},{56,89,67,88},{34,78,90,66}};
float *p;
int i, m;
printf("输入学生学号\n");
scanf("%d",&m);
printf("The scoer of No.%d are:\n",m);
p=search(score,m);
for(i=0; i<4; i++);
printf("%5.2f\n",*(p+i));
printf("\n");
return 0;
}
float * search (float (* pointer)[4] , int n)
{
float * pt;
pt=* (pointer+n);
return (pt);
}
程序2
#include <stdlib.h>
int main()
{
float score[][4]={{60,70,80,90},{56,89,67,88},{34,78,90,66}};
float *search(float (*pointer)[4],int n); //函数声明
float *p;
int i,m;
printf("enter the number of student:");
scanf("%d",&m);
printf("The score of No.%d are:\n",m);
p = search(score,m); //函数调用
for(i=0;i<4;i++)
printf("%5.2f\t",*(p+i));
printf("\n");
return 0;
}
float *search(float (*pointer)[4],int n)
{
float *pt;
pt = *(pointer+n);
return(pt);
}
程序1运行结果不对;
程序2是正确的;
原因找不出呢;
求解;
啊
– 小龙(>^ω^<)喵 6年前