with each % indicating where one of the other (second, third, ...) arguments is to be substituted, and in what form it
is to be printed. For instance, %d specifies an integer argument

augment each %d

For Instance

printf("%3d'F%6d'C\n",Fahrenheit,Celsius);

to print the first number of each line in a field three digits wide, and the second in a field six digits wide,

The printf conversion specification %3.0f says that a floating-point number (here fahr) is to be printed at
least three characters wide, with no decimal point and no fraction digits. %6.1f describes another number
(celsius) that is to be printed at least six characters wide, with 1 digit after the decimal point. The output looks
like this:

printf("%3.1f'F\t%6.1f'C\n",Fahrenheit,Celsius);

0.0'F      -17.8'C
5.0'F -15.0'C
10.0'F -12.2'C
15.0'F -9.4'C
    printf("%3.0f'F\t%6.1f'C\n",Fahrenheit,Celsius);

  'F     -17.8'C
'F -15.0'C
'F -12.2'C
'F -9.4'C
printf("%3.2f'F\t%6.3f'C\n",Fahrenheit,Celsius);

0.00'F    -17.778'C
5.00'F -15.000'C
10.00'F -12.222'C
15.00'F -9.444'C
20.00'F -6.667'C
25.00'F -3.889'C
30.00'F -1.111'C
35.00'F 1.667'C
40.00'F 4.444'C
45.00'F 7.222'C
50.00'F 10.000'C
55.00'F 12.778'C
60.00'F 15.556'C
65.00'F 18.333'C
70.00'F 21.111'C
75.00'F 23.889'C
80.00'F 26.667'C
85.00'F 29.444'C
90.00'F 32.222'C
95.00'F 35.000'C
100.00'F 37.778'C
105.00'F 40.556'C Width and precision may be omitted from a specification:
%6f says that the number is to be at least six characters
wide;
%.2f specifies two characters after the decimal point, but the width is not constrained;
and %f merely says
to print the number as floating point. Among others, printf also recognizes %o for octal, %x for hexadecimal, %c for character, %s for character
string and %% for itself %. uses %f for both float and double; %.0f suppresses the printing of the decimal point and the
fraction part, which is zero.

'%' For instance '%d'的更多相关文章

  1. 再部署一个 instance 和 Local Network - 每天5分钟玩转 OpenStack(131)

    上一节部署了 cirros-vm1 到 first_local_net,今天我们将再部署 cirros-vm2 到同一网络,并创建 second_local_net. 连接第二个 instance 到 ...

  2. 将 instance 部署到 OVS Local Network - 每天5分钟玩转 OpenStack(130)

    上一节创建了 OVS 本地网络 first_local_net,今天我们会部署一个 instance 到该网络并分析网络结构.launch 一个 instance,选择 first_local_net ...

  3. java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE

    Android发出HTTP请求时出现了这个错误: java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INST ...

  4. 严重: Exception sending context initialized event to listener instance of class

    问题描述:Exception sending context initialized event to listener instance of class org.springframework.w ...

  5. 将 instance 连接到 flat_net - 每天5分钟玩转 OpenStack(88)

    上一节我们创建了 "flat_net",本节将在此网络中部署 instance 并验证连通性. launch 新的 instance “cirros-vm1”,选择网络 falt_ ...

  6. DI中Transient Scoped Singleton Instance的区别

    Observe which of the OperationId values varies within a request, and between requests. Transient obj ...

  7. http://www.sqlservercentral.com/articles/Failover+Clustered+Instance+(FCI)/92196/

    http://www.sqlservercentral.com/articles/Failover+Clustered+Instance+(FCI)/92196/ http://blogs.msdn. ...

  8. python class metaclass instance

    >>> class CObj(object):... pass...>>> dir()['CObj', '__builtins__', '__doc__', '__ ...

  9. '-[__NSCFString stringFromMD5]: unrecognized selector sent to instance 0x14d89a50'

    类型:ios 问题描述: 导入百度地图 然后在模拟器运行可以,真机测试不行: 报错: '-[__NSCFString stringFromMD5]: unrecognized selector sen ...

  10. WCF 的 Service Instance模式和并发处理

    WCF 的 Service Instance(实例)有三种模式 PerCall:每一次调用都创建一个实例,每一次调用结束后回收实例.此模式完全无状态. PerSession:调用者打开Channel时 ...

随机推荐

  1. Java 虚拟机是如何判定两个 Java 类是相同的?

    Java 虚拟机是如何判定两个 Java 类是相同的? 答:Java 虚拟机不仅要看类的全名是否相同,还要看加载此类的类加载器是否一样.只有两者都相同的情况,才认为两个类是相同的.即便是同样的字节代码 ...

  2. java实现第七届蓝桥杯阶乘位数

    阶乘位数 阶乘位数 9的阶乘等于:362880 它的二进制表示为:1011000100110000000 这个数字共有19位. 请你计算,9999 的阶乘的二进制表示一共有多少位? 注意:需要提交的是 ...

  3. Linux RPM管理命令

    RPM安装 rpm -ivh 包全名,其中,-i 表示安装,-v 表示显示详细信息,-h 表示显示进度 手动安装会有很多包依赖需要解决,如果是模块依赖,可以使用rpmfind进行查询解决 RPM升级 ...

  4. AbstractCollection类中的 T[] toArray(T[] a)方法源码解读

    一.源码解读 @SuppressWarnings("unchecked") public <T> T[] toArray(T[] a) { //size为集合的大小 i ...

  5. 掌握SpringBoot-2.3的容器探针:基础篇

    欢迎访问我的GitHub 地址:https://github.com/zq2599/blog_demos 内容:原创文章分类汇总,及配套源码,涉及Java.Docker.K8S.DevOPS等 关于& ...

  6. 小技巧:如何用 Chrome 将 SVG 转成 PNG

    怎么把 SVG 转成 PNG ?用 Chrome 吧,非常好用,还能设定自己想要的尺寸. 什么是 SVG ? SVG (Scalable Vector Graphics,可缩放矢量图形) 是基于 XM ...

  7. Cookie 与 SessionID 的本质

    当用户首次访问服务器的时候,服务器为每个用户单独创建一个 Session 对象,并分配一个新的 SessionID,此时 SessionID 通过 Cookie 保存在用户端. 当用户再次访问服务器的 ...

  8. (九)maven-compiler-plugin 插件详解

    <plugin> <!-- 指定maven编译的jdk版本,如果不指定,maven3默认用jdk 1.5 maven2默认用jdk1.3 --> <groupId> ...

  9. 操作-读取excel

    xlrd 该模块主要用来读取excel 注:sheet表示的是excel的表,就是底下的工作栏 (1) 打开excel文件并获取所有sheet import xlrd # 打开Excel文件读取数据 ...

  10. JVM进阶之路(一)

    JVM是Java程序运行的基本,了解Java程序的运行原理绝对有必要了解JVM的内容,JVM的内容其实很多,而且版本不同,其中的内容也很多不同,接下来就通过几篇文章来慢慢讲述JVM的内容. 一.Jvm ...