当前位置:网站首页>C language basic practice (nine-nine multiplication table) and printing different asterisk patterns
C language basic practice (nine-nine multiplication table) and printing different asterisk patterns
2022-07-31 14:09:00 【Script kid】
C语言实现九九乘法表的输出
#include<stdio.h>
int main()
{
int i = 0;
for (i = 1; i <= 9; i++)
{
int j = 0;
for (j = 1; j <= i; j++)
{
printf("%d*%d=%d ", i, j, i * j);
}
printf("\n");
}
return 0;
}
输出为
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
D:\visual studio program\demo.cpp\x64\Debug\ConsoleApplication5.exe (进程 11860)已退出,代码为 0.
要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”.
按任意键关闭此窗口. .
打印平行四边形
#include <stdio.h>
int main()
{
int i, j, n;
scanf("%d", &n);//The number of lines to print the parallelogram
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
printf(" ");
}
for (j = 1; j <= n; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
打印顶角朝上的等腰三角形
#include <stdio.h>
int main()
{
int i, j, n;
scanf("%d", &n);//Print the number of rows of an isosceles triangle
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
printf(" ");
}
for (j = 1; j <= 2 * i - 1; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
打印top corner down的等腰三角形
#include <stdio.h>
int main ()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i-1;j++)
{
printf(" ");
}
for(j=1;j<=2*n-2*i+1;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
边栏推荐
- MySQL [aggregate function]
- 动作捕捉系统用于柔性机械臂的末端定位控制
- Comparison of Optical Motion Capture and UWB Positioning Technology in Multi-agent Cooperative Control Research
- MySQL 23 classic interviews hang the interviewer
- 49.【拷贝构造函数与重载】
- endnote引用
- 1-hour live broadcast recruitment order: industry leaders share dry goods, and enterprise registration is open丨qubit · point of view
- CodeIgniter 打开错误日志
- A detailed guide to simulating latency with SQL/JDBC
- 我把问烂了的MySQL面试题总结了一下
猜你喜欢
AWS实现定时任务-Lambda+EventBridge
动作捕捉系统用于柔性机械臂的末端定位控制
Resolved (pymysqL connect to the database error) pymysqL. Err. ProgrammingError: (1146, "Table" test. Students' doesn 't exist ")
Miller_Rabin 米勒拉宾概率筛【模板】
4.爬虫之Scrapy框架2数据解析&配置参数&数据持久化&提高Scrapy效率
拥塞控制,CDN,端到端
以后面试官问你 为啥不建议使用Select *,请你大声回答他!
Nuget package and upload tutorial
CLion用于STM32开发
Even if the image is missing in a large area, it can also be repaired realistically. The new model CM-GAN takes into account the global structure and texture details
随机推荐
DELL SC compellent 康贝存储系统怎么抓取配置信息
C#高级--委托
Open Inventor 10.12 重大改进--和谐版
C# Get network card information NetworkInterface IPInterfaceProperties
CLion用于STM32开发
uniapp微信小程序引用标准版交易组件
All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
go使用makefile脚本编译应用
leetcode: 485. Maximum number of consecutive 1s
The JVM a class loader
组合系列--有排列就有组合
Shell项目实战1.系统性能分析
The use of C# control CheckBox
The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
MySQL【子查询】
什么是消息队列呢?
Reasons and solutions for Invalid bound statement (not found)
Resnet&API
[QNX Hypervisor 2.2用户手册]9.14 safety
Nuget打包并上传教程