当前位置:网站首页>C- print 99 multiplication table
C- print 99 multiplication table
2022-06-11 07:42:00 【Zhangxueheng】
Here's a complete list of the bottom triangle and nine nines :
1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
For any given 1 Positive integer N, Output from 1*1 To N*N Part of the formula table .
Input format :
Input gives a positive integer on a line N(1<=N<=9).
Output format :
Output the lower triangle N*N Part of the formula table , The number to the right of the equal sign is 4 position 、 Align left .
sample input :
4
sample output :
1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16
Code details :
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int i,j;
i=1;
while(i<=n){
j=1;
while(j<=i){
printf("%d*%d=%d",i,j,i*j);
if(i*j<10){
printf(" ");
}else{
printf(" ");
}
j++;
}
printf("\n");
i++;
}
}
First enter a variable n, For user input , Variable i,j Is the number of rows and columns of the multiplication table . According to the title, we can see that the format is x*y form , So it can be inferred that a two-layer loop . According to the space after each number , Can make a judgment , If it's a single digit , Print three spaces , If it is two digits, print two spaces .
The result is shown in the figure :

边栏推荐
- Djikstra solves the shortest circuit with negative weight
- 群晖DS918创建m.2 固态硬盘SSD读写缓存
- 【Oracle 数据库】奶妈式教程day03 排序查询
- 【AtCoder2304】Cleaning
- C language to write a calculator MVC (very interesting code architecture callback and constructor mode and the use of pointer functions)
- C# 微信上传Form-data
- Sdl-3 YUV playback
- 20200803 T3 my friends [divide and conquer NTT optimization recursion]
- Use of wordcloud
- [atcoder1980] mystious light (mathematical simulation)
猜你喜欢

【IoT】项目管理:如何打造更好的跨职能团队?

Seata的几种事务模式

Sdl-2 thread logic

Simple configuration of vscade
![[Oracle database] mammy tutorial day02 use of database management tool sqlplus](/img/f2/8f6f74a62427ebfb4c805c1e9b3352.png)
[Oracle database] mammy tutorial day02 use of database management tool sqlplus

C# 微信上传Form-data

Black Qunhui dsm7.0.1 physical machine installation tutorial

如何准备PMP新版大纲考试?

C language inherits memory management mechanism (unfinished)

【AtCoder1980】Mysterious Light(数学模拟)
随机推荐
C language inherits memory management mechanism (unfinished)
【集群】haproxy负载均衡
【AtCoder2307】Tree Game(博弈)
Qunhui ds918 creates m.2 SSD read / write cache
排序——交换排序
pmp到底是什么?
Ffmpeg extraction package format extracts AAC and customizes adtc header to realize arbitrary frame decoding
Implementation of stack (C language)
二本畢業,銀行外包測試工作 4 個月有餘。聊聊一些真實感受 ...
multi-sig SC
运筹学导论
黑群晖DSM7.0.1物理机安装教程
nosqlzoo刷题-1
Miscellany C language
Paging of the flask page
Compound RateModel合約解析
A correction book full of sad tears
【CodeForces1019E】Raining season(边分治+斜率优化)
[atcoder2376] black and white tree (game)
【IoT】智能硬件:如何获取硬件产品的wifi信号强度