'%' For instance '%d'
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'的更多相关文章
- 再部署一个 instance 和 Local Network - 每天5分钟玩转 OpenStack(131)
上一节部署了 cirros-vm1 到 first_local_net,今天我们将再部署 cirros-vm2 到同一网络,并创建 second_local_net. 连接第二个 instance 到 ...
- 将 instance 部署到 OVS Local Network - 每天5分钟玩转 OpenStack(130)
上一节创建了 OVS 本地网络 first_local_net,今天我们会部署一个 instance 到该网络并分析网络结构.launch 一个 instance,选择 first_local_net ...
- java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE
Android发出HTTP请求时出现了这个错误: java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INST ...
- 严重: Exception sending context initialized event to listener instance of class
问题描述:Exception sending context initialized event to listener instance of class org.springframework.w ...
- 将 instance 连接到 flat_net - 每天5分钟玩转 OpenStack(88)
上一节我们创建了 "flat_net",本节将在此网络中部署 instance 并验证连通性. launch 新的 instance “cirros-vm1”,选择网络 falt_ ...
- DI中Transient Scoped Singleton Instance的区别
Observe which of the OperationId values varies within a request, and between requests. Transient obj ...
- http://www.sqlservercentral.com/articles/Failover+Clustered+Instance+(FCI)/92196/
http://www.sqlservercentral.com/articles/Failover+Clustered+Instance+(FCI)/92196/ http://blogs.msdn. ...
- python class metaclass instance
>>> class CObj(object):... pass...>>> dir()['CObj', '__builtins__', '__doc__', '__ ...
- '-[__NSCFString stringFromMD5]: unrecognized selector sent to instance 0x14d89a50'
类型:ios 问题描述: 导入百度地图 然后在模拟器运行可以,真机测试不行: 报错: '-[__NSCFString stringFromMD5]: unrecognized selector sen ...
- WCF 的 Service Instance模式和并发处理
WCF 的 Service Instance(实例)有三种模式 PerCall:每一次调用都创建一个实例,每一次调用结束后回收实例.此模式完全无状态. PerSession:调用者打开Channel时 ...
随机推荐
- Java实现 LeetCode 432 全 O(1) 的数据结构
432. 全 O(1) 的数据结构 实现一个数据结构支持以下操作: Inc(key) - 插入一个新的值为 1 的 key.或者使一个存在的 key 增加一,保证 key 不为空字符串. Dec(ke ...
- Java实现第八届蓝桥杯分巧克力
分巧克力 题目描述 儿童节那天有K位小朋友到小明家做客.小明拿出了珍藏的巧克力招待小朋友们. 小明一共有N块巧克力,其中第i块是Hi x Wi的方格组成的长方形. 为了公平起见,小明需要从这 N 块巧 ...
- 除了FastJson,你也应该了解一下Jackson(一)
在上月末的时候收到一条关于fastjson安全漏洞的消息,突然想到先前好像已经有好多次这样的事件了(在fastjson上面).关于安全方面,虽然中枪的机率微小,但是在这个信息越来越复杂的时代,安全性也 ...
- 纯CSS如何实现状态圆点
.circle { display: inline-block; width: 12px; height: 12px; } .circle:after { content: ''; margin: 3 ...
- SpringBoot设置mysql的ssl连接
因工作需要,mysql连接需要开启ssl认证,本文主要讲述客户端如何配置ssl连接. 开发环境信息: SpringBoot: 2.0.5.RELEASE mysql-connector-java: 8 ...
- Linux系统管理——Linux简介
UNIX与Linux发展史 UNIX发展历史 1.1965年,美国麻省理工学院(MIT),通用电气公司(GE)及AT&T的贝尔实验室联合开发Multics工程计划,其目标是开发一种交互式的具有 ...
- 基于mykernel2.0编写一个操作系统内核
基于mykernel2.0编写一个操作系统内核 一. 实验准备 详细要求 基于mykernel 2.0编写一个操作系统内核 按照https://github.com/mengning/mykernel ...
- 曹工说Redis源码(8)--面试时,redis 内存淘汰总被问,但是总答不好
文章导航 Redis源码系列的初衷,是帮助我们更好地理解Redis,更懂Redis,而怎么才能懂,光看是不够的,建议跟着下面的这一篇,把环境搭建起来,后续可以自己阅读源码,或者跟着我这边一起阅读.由于 ...
- css在 IE8下的兼容性
常用伪类选择器 IE7 IE8 IE9 :hover √ √ √ :focus × √ √ :first-child √ √ √ :last-child × × √ :first-of-type ...
- 030.Kubernetes核心组件-Scheduler
一 Scheduler原理 1.1 原理解析 Kubernetes Scheduler是负责Pod调度的重要功能模块,Kubernetes Scheduler在整个系统中承担了"承上启下&q ...