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实现 LeetCode 284 顶端迭代器

    284. 顶端迭代器 给定一个迭代器类的接口,接口包含两个方法: next() 和 hasNext().设计并实现一个支持 peek() 操作的顶端迭代器 – 其本质就是把原本应由 next() 方法 ...

  2. Java实现 LeetCode 220 存在重复元素 III(三)

    220. 存在重复元素 III 给定一个整数数组,判断数组中是否有两个不同的索引 i 和 j,使得 nums [i] 和 nums [j] 的差的绝对值最大为 t,并且 i 和 j 之间的差的绝对值最 ...

  3. java实现第六届蓝桥杯九数组分数

    九数组分数 九数组分数 1,2,3...9 这九个数字组成一个分数,其值恰好为1/3,如何组法? 下面的程序实现了该功能,请填写划线部分缺失的代码. public class A { public s ...

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

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

  5. MMDVM中继板测试软件MMDVMCal

    运行方法: 只支持windows 64位系统 32位下载:https://share.weiyun.com/52uHAO5 64位下载:https://share.weiyun.com/5IgdqvL ...

  6. CDN百科 | 最近,你的APP崩了吗?

    过去几个月里,#xxx崩了#这个话题频繁出现在热搜榜上,让不少程序员小哥哥瑟瑟发抖. 从疫情宅家时期著名的视频APP“三连崩”,到全面复工开课后的在线教育平台与办公软件频繁宕机,再到报复性消费引发的点 ...

  7. Oracle RMAN各类压缩算法对比测试

    1.背景概述 2.本次测试环境基本信息 3.测试步骤 3.1. 使用BCO进行压缩备份 3.2. 不使用压缩备份 3.3. 使用ACO中LOW级别进行压缩备份 3.4. 使用ACO中MEDIUM级别进 ...

  8. 面试官:换人!他连 TCP 这几个参数都不懂

    每日一句英语学习,每天进步一点点: 前言 TCP 性能的提升不仅考察 TCP 的理论知识,还考察了对于操心系统提供的内核参数的理解与应用. TCP 协议是由操作系统实现,所以操作系统提供了不少调节 T ...

  9. 【分区】使用 GPT 分区表分区并格式化 (非 FreeBSD 系统)

    新购买的 Linux 云服务器,由于数据盘未做分区和格式化,无法使用. 注意: 数据盘中的数据在格式化后将全部被清空.请在格式化之前,确保数据盘中没有数据或已对重要数据进行备份.为避免服务发生异常,格 ...

  10. pip install 执行过程中遇到的各种问题

    一.pip install 安装指定版本的包 要用 pip 安装指定版本的 Python 包,只需通过 == 操作符 指定. pip install robotframework == 2.8.7 将 ...