c语言printf 空格,在打印输出前面添加空格,如在C中[printf(%2i)]
我已经用C编写了这个练习,在那里我能够在printf(%2i)和printf(%3i)的帮助下输出格式良好的表。在
在Python中,如何在数字前面添加空格以使其看起来更好?在#! python3
# 007.py - Write a program that prints a multiplication table for numbers up to 12.
print('----------------------------------------')
print('Multiplication Table from 1 - 12')
print('----------------------------------------')
print(' 1 2 3 4 5 6 7 8 9 10 11 12')
print('----------------------------------------')
for i in range(1, 13):
if i > 1:
print('\n', end="")
print(' ' + str(i) + ' |', end="")
result = i
for n in range(1, 13):
result = i * n
print(' ' + str(result), end="")
print('\n')
print('----------------------------------------')
输出:
^{pr2}$
C代码:/**
* Write a program that prints a multiplication table
* for numbers up to 12.
* 15.12.2016
*/
#include
int main(void)
{
int result;
printf ("-----------------------------------------------------\n");
printf ("\tMultiplication Table from 1 - 12\n");
printf ("-----------------------------------------------------\n");
printf (" 1 2 3 4 5 6 7 8 9 10 11 12\n");
printf ("-----------------------------------------------------\n");
for (int i = 1; i <= 12; ++i)
{
if (i > 1)
{
printf ("\n");
}
printf (" %2i | ", i);
result = i;
for (int n = 1; n <= 12; ++n)
{
result = i * n;
printf ("%3i ", result);
}
}
printf ("\n");
printf ("-----------------------------------------------------\n");
return 0;
}
输出:Multiplication Table from 1 - 12
-----------------------------------------------------
1 2 3 4 5 6 7 8 9 10 11 12
-----------------------------------------------------
1 | 1 2 3 4 5 6 7 8 9 10 11 12
2 | 2 4 6 8 10 12 14 16 18 20 22 24
3 | 3 6 9 12 15 18 21 24 27 30 33 36
4 | 4 8 12 16 20 24 28 32 36 40 44 48
5 | 5 10 15 20 25 30 35 40 45 50 55 60
6 | 6 12 18 24 30 36 42 48 54 60 66 72
7 | 7 14 21 28 35 42 49 56 63 70 77 84
8 | 8 16 24 32 40 48 56 64 72 80 88 96
9 | 9 18 27 36 45 54 63 72 81 90 99 108
10 | 10 20 30 40 50 60 70 80 90 100 110 120
11 | 11 22 33 44 55 66 77 88 99 110 121 132
12 | 12 24 36 48 60 72 84 96 108 120 132 144
-----------------------------------------------------
c语言printf 空格,在打印输出前面添加空格,如在C中[printf(%2i)]相关推荐
- Word2019中Visio对象图片插入题注时自动删除标签与编号前的空格,编号后添加空格
问题引入 撰写论文时为了修改方便,通常以插入题注和交叉引用的方式来给图片标号,这样修改图片和图号后可以方便.自动地更新. 然而,Word在插入题注上从03到13一直没有针对中国用户优化. 插入题注的标 ...
- Word插入题注优化(自动删除标签与编号前的空格,编号后添加空格)
简介 最近在论文写作时发现,对图或者表右击进行插入题注时格式有点不正确,会在标签和编号之间多一个半角空格,而编号和题注内容之间又缺少一个空格,这也是Word目前对中文支持不太好的地方.我们常规的格式应 ...
- 去掉图题注 空格_【转载】论文排版-Word插入题注时自动删除标签与编号前的空格,编号后添加空格...
Sub InsertCaption()'修改系统插入"题注"命令 '功能:自动删除标签与编号间的空格(英文除外),并在题注数字后添加一个空格:适用于:Word 2003 - 201 ...
- python末尾加空格,如何在后面添加空格字符串.标点符号在Python中?
我想清理我的评论数据.我的代码是:def processData(data): data = data.lower() #casefold data = re.sub(']*>',' ',dat ...
- c语言 读取TXT 去空格,C语言读取TXT文件,忽略文件空格,把内容写入数组中应该如何实现...
C语言读取TXT文件,忽略文件空格,把内容写入数组中应该怎么实现? #include #include #define SIZE_view 50 struct view_info { int id; ...
- c语言:输入一个字符串,统计字母,数字,空格出现的个数,c - 统计字符串字母,空格,数字,其他字符的个数和行数....
#include #include using namespace std; /* 题目:输入一行字符,分别统计出其中英文字母.空格.数字和其它字符的个数. */ void count() { //统 ...
- php怎么添加空格,php给每个段落添加空格的方法
php给每个段落添加空格的方法 本文实例讲述了php给每个段落添加空格的方法.分享给大家供大家参考.具体实现方法如下: //Prepends whitespace to each line of a ...
- java中printf%4d_c语言编程问题: printf(%4d,a[i][j]);里面的数字4是起什么作用的?
c语言编程问题: printf("%4d",a[i][j]);里面的数字4是起什么作用的?以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发 ...
- Android TextVeiw 在java代码中添加空格的方法
可以使用uniconde 的编码设置空格,有三种方法的 \u00A0,\u0020,\u3000 代码设置下 textView.setText("北\u00A0京"); textV ...
最新文章
- php删除修改例,PHP轻量级数据库操作类Medoo增加、删除、修改、查询例子
- 从“共享马扎”的营销,看共享经济的刷屏玩法
- bitcoin 在ubuntu上的安装指南
- Tomcat中部署后JspFactory报异常的解决方案
- Android--批量插入数据到SQLite数据库
- 推荐系统——Wide Deep
- (字符串)字符串中首先出现两次的字符
- VS2013 MFC 直接将 OpenCV2.0/3.0 库中的 Mat 结构的图像传递到 Picture Control(图片控件)
- Python让繁琐工作自动化——chapter17 操作图像
- MATLAB寻找高斯光束光斑中心
- java 资格证_程序员从业资格证
- sip php 来电,php - 如何在Twilio上传递原来的来电显示? (Sip域语音URL配置) - SO中文参考 - www.soinside.com...
- 算法设计与分析-习题-用生成函数求解递归方程f(n)=2f(n/2)+cn,f(1)=0
- 提升思维品质,不可不知的5个工具
- 大数据使磁带重获新生
- QUIC协议原理详解
- 如何在mac上播放iphone音频
- 域环境SID相同到底有什么影响?
- C#毕业设计——基于C#+asp.net+sqlserver的视频点播系统设计与实现(毕业论文+程序源码)——视频点播系统
- c语言经典测试,c语言经典写作测试(非常完整).doc