资源描述
第8章 函 数三、编程题8.17 请编写函数,其功能是对传送过来的两个浮点数求出和值和差值,并通过形参传送回调用函数。#include void fun(float a, float b, float *add, float *sub)*add = a + b;*sub = a - b;void main()float m,n,r,s;scanf(%f%f,&m,&n);fun(m,n,&r,&s);printf(%f+%f=%fn,m,n,r);printf(%f-%f=%fn,m,n,s);8.18 请编写函数,对传送过来的三个数选出最大数和最小数,并通过形参传回调用函数。#include void fun(int a, int b, int c, int *max, int *min)*max = ab?a:b ;*max = *maxc?*max:c;*min = ab?a:b ;*min = *minc?*min:c;void main()int m,n,p,nmax,nmin;scanf(%d%d%d,&m,&n,&p);fun(m,n,p,&nmax,&nmin);printf(max=%dn,nmax);printf(min=%dn,nmin);
展开阅读全文