首页 > 代码库 > 第十次作业

第十次作业

1.拆分整数与小数部分

#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);
}

技术分享

 

2.找最大值

#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);
    
}

技术分享

3.计算两个数的和与差

#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);
}

技术分享

第十次作业