C语言学习记录

牛牛学说话之-浮点数_牛客题霸_牛客网 (nowcoder.com)

#include<stdio.h>
int main()
{
    float a;//浮点数也就是小数,有两种定义形式,分别是float和double
    scanf("%f",&a);//%f对应float,%lf对应double,就像%d对应整数int一样
    printf("%.3f",a);//保留3位小数为.3f,保留1位小数为.1f
    return 0;
}

float和double的区别:

float:所占内存小,运行速度快

double:能定义的数范围更大,更精确

相关推荐

  1. C语言 学习记录】五、函数

    2024-02-12 16:56:01       54 阅读
  2. C语言 学习记录】七、指针

    2024-02-12 16:56:01       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-12 16:56:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-12 16:56:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-12 16:56:01       87 阅读
  4. Python语言-面向对象

    2024-02-12 16:56:01       96 阅读

热门阅读

  1. git安装及使用

    2024-02-12 16:56:01       64 阅读
  2. Mac中管理多版本Jdk

    2024-02-12 16:56:01       69 阅读
  3. EBITDA/息税前利润

    2024-02-12 16:56:01       55 阅读
  4. Composite Pattern File System

    2024-02-12 16:56:01       46 阅读
  5. 【More Effective C++】条款5:警惕隐式类型转换

    2024-02-12 16:56:01       61 阅读
  6. js_表格全选反选

    2024-02-12 16:56:01       44 阅读
  7. Leetcode 300 最长递增子序列

    2024-02-12 16:56:01       55 阅读
  8. Leetcode 3036. Number of Subarrays That Match a Pattern II

    2024-02-12 16:56:01       69 阅读
  9. C# Avalonia 折线图

    2024-02-12 16:56:01       58 阅读