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实现Synchronized锁的用法

    Java线程同步中的一个重要的概念synchronized. synchronized是java的关键字,是一种同步锁,它作用的对象有以下几种: ①作用在代码块上.该代码块称为同步代码块,作用范围是大 ...

  2. java实现取球游戏

    /* 今盒子里有 n 个小球,A.B 两人轮流从盒中取球,每个人都可以看到另一个人取了多少个, 也可以看到盒中还剩下多少个,并且两人都很聪明,不会做出错误的判断. 我们约定: 每个人从盒子中取出的球的 ...

  3. 数据结构:用实例分析ArrayList与LinkedList的读写性能

    目录 背景 ArrayList LinkedList 实例分析 1.增加数据 2.插入数据 3.遍历数据 3.1.LinkedList遍历改进 总结 背景 ArrayList与LinkedList是J ...

  4. 原声js数组去重方法

    数组去重方法 方法一 ---- 利用数组filter + indexOf方法去重 方法二 ---- 利用数组forEach + indexOf方法去重 方法三 ---- 利用数组from方法 + Se ...

  5. 官宣!ASF官方正式宣布Apache Hudi成为顶级项目

    马萨诸塞州韦克菲尔德(Wakefield,MA)- 2020年6月 - Apache软件基金会(ASF).350多个开源项目和全职开发人员.管理人员和孵化器宣布:Apache Hudi正式成为Apac ...

  6. MySQL 8.0 yum安装和配置

    MySQL 8.0 centos7.5 x86_64 一.yum安装 1.先卸载机器和mysql有关的东西,有的安装了mariab-lib,会对安装有干扰,卸载了它. [root@localhost ...

  7. zabbix 交换机端口显示端口描述

    ZABBIX 监控系统流量图显示端口描述   进入web 选择配置--主机 选择触发器原型 编辑触发器 随便点开一个触发器 选择触发器原型   逐个点开修改 {#IFDESCR}: ({#IFALIA ...

  8. kafka能做什么?kafka集群配置 (卡夫卡 大数据)

    什么是Kafka 官网介绍: 几个概念: 详细介绍 : 操作kafka: kafka集群 消息测试 问题检测 什么是Kafka 官网介绍: ApacheKafka是一个分布式流媒体平台.这到底是什么意 ...

  9. linux下解决vim打开文件乱码现象

    用VIM打开一个文件进行编辑时最下面的任务栏出现中文乱码,严重影响编写代码. 因为VIM默认的语言支持不行, 修改~/.vimrc 文件或/etc/vimrc 文件,添加一下代码: set encod ...

  10. (六)POI-操作Excel的poi的字体设置

    原文链接:https://blog.csdn.net/class157/article/details/92817286 package com.java.poi; import org.apache ...