'%' 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实现控制台版CS
也可以把这四个类直接复制下去放在一个包下面 父类 package Cs1_6; public abstract class Persion { public abstract void Attack( ...
- Python爬虫 requests库基础
requests库简介 requests是使用Apache2 licensed 许可证的HTTP库. 用python编写. 比urllib2模块更简洁. Request支持HTTP连接保持和连接池,支 ...
- iOS-MapKit的使用笔记
对于地图和定位,苹果公司提供给了两个框架: MapKit:用于地图展示 Core Location :用于地理定位 这次总结MapKit: 同样,在使用MapKit时首先要导入头文件: 与 ...
- CentOS 6.X 双网卡绑定配置
相关环境 主机:Dell PowerEdge R720服务器(背板有4个GE网口) 操作系统:CentOS(RHEL)6.X 网线连接 使用6类网线 将Dell R720 GE网口 0,与交换机A相连 ...
- SwiftUI - iOS10本地推送通知教程UserNotifications在Swift中的实现方式
简介 消息推送相信在很多人的眼里都不陌生了吧?像即时聊天微信,好友发信息给你时会在顶部弹下小窗口提醒你.也像是在影院APP预订了电影票,在开场前一小时你也会收到提醒.这类推送是需要经过后端发送请求的, ...
- Spark Streaming + Kafka Integration Guide原文翻译及解析
前面写了关于kafka和spark streaming的结合使用(https://www.cnblogs.com/qfxydtk/p/11662591.html),其具体使用用法其实来自于原文:htt ...
- @codeforces - 607E@ Cross Sum
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 n 条直线,构造可重点集合 I 为 n 条直线两两的交点集 ...
- [源码解析] GroupReduce,GroupCombine 和 Flink SQL group by
[源码解析] GroupReduce,GroupCombine和Flink SQL group by 目录 [源码解析] GroupReduce,GroupCombine和Flink SQL grou ...
- Web测试和app测试区别?
EB测试和APP测试从流程上来说,没有区别.都需要经历测试计划方案,用例设计,测试执行,缺陷管理,测试报告等相关活动.从技术上来说,WEB测试和APP测试其测试类型也基本相似,都需要进行功能测试,性能 ...
- cb15a_c++_vector容器的自增长_每次增加百分之50
cb15a_c++_vector容器的自增长_每次增加百分之50每次自动容量代销扩充,增加百分之50_for windows C++,vector是用数组做出来的->数组的缺点和优点优点:具有下 ...