#include<stdio.h> int main() { int *search(int (*s)[4],int n); int sorce[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}}; int n,i; int (*p)[4]; p=sorce; printf("请输入你要搜索的学生号\n"); scanf("%d",&n); for(i=0;i<4;i++) printf("%d ",*(search(p,n)+1)); return 0; } int *search(int (*s)[4],int n) { return *(s+n-1); }
不知道哪里出错了 帮本人看看吧
解决方案
80
printf(“%d “,*(search(p,n)+1));应该是printf(“%d “,*(search(p,n)+i));
#include<stdio.h> int main() { int *search(int (*s)[4],int n); int sorce[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}}; int n,i; int (*p)[4]; p=sorce; printf("请输入你要搜索的学生号\n"); scanf("%d",&n); for(i=0;i<4;i++) printf("%d ",*(search(p,n)+i)); return 0; } int *search(int (*s)[4],int n) { return *(s+n-1); }