亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

返回指針值的函數

返回指針值的函數

繁星coding 2018-08-13 15:14:56
程序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是正確的;原因找不出呢;求解;
查看完整描述

1 回答

?
呼喚遠方

TA貢獻1856條經驗 獲得超11個贊

程序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);
}

把for后面的;去掉

查看完整回答
反對 回復 2018-09-11
  • 1 回答
  • 0 關注
  • 884 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號