补交第九次作业
拆分 整数与小数
#include <stdio.h> void sum_diff(float op1,float op2,float *psum , float* pdiff) { *psum = op1+op2; *pdiff = op1-op2; } int main(void) { float f1=11.1, f2=1.5, sum, diff; sum_diff(f1, f2, &sum, &diff); printf("sum=%g, diff=%g\n", sum, diff); }
最大值
#include<stdio.h> void findmax( int *px, int *py, int *pmax ) { *pmax = *px; if(*py > *pmax) *pmax = *py; } int main(void) { int max,x,y; scanf("%d%d",&x,&y); findmax(&x,&y,&max); printf("max:%d\n",max); }
两个数和与差的计算
#include <stdio.h> void sum_diff(float op1,float op2,float *psum , float* pdiff) { *psum = op1+op2; *pdiff = op1-op2; } int main(void) { float f1=11.1, f2=1.5, sum, diff; sum_diff(f1, f2, &sum, &diff); printf("sum=%g, diff=%g\n", sum, diff); }