• 已知float后几位,谋几位保留


                                                  设变量n为float类型,m为int类型,则以下能实现将n中的数值保留小数点后两位,第三位进行四舍五入运算的表达式____.

    #include "common.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    //#define 
    static float Mathematical_modeling = 0;
    static int   capacitance_modeling  = 0;
    static float value = 0;
    static char  car = 'A';
    static float bus_num = -1000.123;
    static int   China_population = -100;
    static float x = 2.5, y = 4.7;
    static int a = 7;
    //m=         (int)
    //n=1.3456   (float)
    static float test_n = 1.3456;
    static int   test_m = 0;
    
    int main()
    {
        
        int tmp = 2 / 4;
        test_m = test_n * 100 + 0.5;
        test_n = test_m / 100.0;
    
        //x+y 
        printf("类型转换is %f\n",x+a%3*(int)(x + y)%2/4);
        printf("tmp is %d\n", tmp);
        printf("test_n is %f\n",test_n);
    
        while (1)
        {
            getchar();
        }
    
        return 0;
    } 
    一勤天下无难事。
  • 相关阅读:
    jquey 阻止表单提交
    Array.prototype.remove 删除数组元素
    <asp:HiddenField> 控件 实现键值对保存
    jquery实现倒计时
    作业
    第六周作业
    第四周作业
    第二次作业
    2021.3.4(四个题)
    增删改查
  • 原文地址:https://www.cnblogs.com/nowroot/p/12373981.html
Copyright © 2020-2023  润新知