1、实验 9 指针(1) 答案此答案为书本上实验 9 指针(1) 的答案,实验 x 就是对应的 9-x.实验一的足迹:#includevoid main()int ia23=2,4,6,8,10,12,(*pa)3,i,j;pa=ia;scanf(“%d,%d“,printf(“ia%d%d=%dn“,i,j,*(*(pa+i)+j);*实验 9.2*实验二的足迹:#includevoid main()int ia,ib,*pa=scanf(“%d,%d“,pa,pb);if(*pa*pb)p=pa;pa=pb;pb=p;printf(“%dfun(int *pa,int *pb)int item
2、p;itemp=*pa;*pa=*pb;*pb=itemp; void main()int ia,ib;int *pa,*pb;scanf(“%d,%d“,pa=pb=if(iafun()int *pa,i,ia5;pa=ia;for(i=0;ivoid main()int ia, *pa=printf(“请输入一个整型变量 ia:n“);scanf(“%d“,printf(“%dn“,*pa);*实验 9.6*实验六的程序:#includefun(int a,int b)int c;c=a;a=b;b=c;printf(“交换后的 a,b 的值为: %d,%dn“,a,b);void mai
3、n()int *ia,*ib;printf(“请输入 ia 和 ib 两变量的值: n“);scanf(“%d,%d“,fun(ia,ib);*实验 9.7*实验七的程序:*实验 9.8*实验八的程序:#includevoid main()int iA,iB,*PI;int *max(int iX,int iY);scanf(“%d%d“,PI=max(iA,iB);printf(“max=%dn“,*PI);int *max(int iX,int iY)if(iX#includeint callfun(int (*pfun)(int iA,int iB),int iA,int iB);int
4、 fmax(int iA,int iB);void main()int iA,iB;printf(“输入两个整数:“);scanf(“%d%d“,printf(“%d 和%d 的最大值是%dn“,iA,iB,callfun(fmax,iA,iB);int callfun(int (*pfun)(int iA,int iB),int iA,int iB)int fvalue;fvalue=(*pfun)(iA,iB);return fvalue;int fmax(int iA,int iB)return(iAiB?iA:iB);#include#includeint callfun(int (*
5、pfun)(int iA,int iB),int iA,int iB);int fmax(int iA,int iB);void main()int iA,iB;printf(“输入两个整数:“);scanf(“%d%d“,printf(“%d 和%d 的最大值是%dn“,iA,iB,callfun(fmax,iA,iB);int callfun(int (*pfun)(int iA,int iB),int iA,int iB)int fvalue;fvalue=(*pfun)(iA,iB);return fvalue;int fmax(int iA,int iB)return(iAiB?iA:iB);*实验十*实验十的程序:#define N 3#define M 3#include“stdio.h“select(int iANM,int *iN)int i,j,irow=1,icolum=1;for(i=0;iiAirowicolum)irow=i;icolum=j;*iN=irow;return iAirowicolum;void main()int iANM=9,11,23,6,1,15,9,17,20,imax,iN;imax=select(iA,printf(“max=%d,line=%dn“,imax,iN);