• 第十次作业


    1.拆分整数与小数部分


    #include <stdio.h>
    int main(void)
    {
    double x,y,z,*intpart=&y,*fracpart=&z;
    void splitfloat (double x, double *intpart, double *fracpart);
    printf(" ");
    scanf("%lf", &x);
    splitfloat(x, intpart, fracpart);
    printf("整数部分是: %.2lf ",*intpart);
    printf("小数部分是:%.6lf ",*fracpart);
    return 0;
    }
    void splitfloat (double x, double *intpart, double *fracpart)
    {
    *intpart=(int)x;
    *fracpart=x-*intpart;
    }

    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
    ",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
    ", sum, diff);
    }

  • 相关阅读:
    没有一个计时器控制在VB6计时器功能
    检测系统范围内的鼠标事件
    c# Com
    tcpdump
    dd
    dumpe/dumpe2fs/e2fsck
    fdisk
    mkswap/swapon/swapoff/free
    mkfs/mk2fs/fsck/e2fsck/tune2fs/blkid
    parted
  • 原文地址:https://www.cnblogs.com/moyansameal/p/6106419.html
Copyright © 2020-2023  润新知