当前位置:网站首页>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;
}
边栏推荐
- Shell script classic case: backup of files
- 技能大赛训练题: 子网掩码划分案例
- redhat/openssl generates a self-signed ca certificate and uses it
- 【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
- 小试牛刀:Go 反射帮我把 Excel 转成 Struct
- hyperf的启动源码分析(二)——请求如何到达控制器
- 新款现代帕里斯帝预售开启,安全、舒适一个不落
- ADS communicate with c #
- LeetCode rotate array
猜你喜欢
The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%
csdn发文助手问题
技能大赛训练题:登录安全加固
五个维度着手MySQL的优化
For enterprises in the digital age, data governance is difficult, but it should be done
尚硅谷-JVM-内存和垃圾回收篇(P1~P203)
DELL SC compellent 康贝存储系统怎么抓取配置信息
C# Get network card information NetworkInterface IPInterfaceProperties
AWS implements scheduled tasks - Lambda+EventBridge
深度剖析 Apache EventMesh 云原生分布式事件驱动架构
随机推荐
Linux bash: redis-server: command not found
All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
C# using ComboBox control
Sliding window method to segment data
Motion capture system for end-positioning control of flexible manipulators
In the future, the interviewer asks you why it is not recommended to use Select *, please answer him out loud!
Node version switching management using NVM
Miller_Rabin 米勒拉宾概率筛【模板】
STM32的CAN过滤器
技能大赛训练题:域用户和组织单元的创建
代码随想录笔记_哈希_454四数相加II
Shell脚本经典案例:文件的备份
搭建私有的的Nuget包服务器教程
el-tooltip的使用
【redis】发布和订阅消息
IDEA can't find the Database solution
什么是消息队列呢?
3.爬虫之Scrapy框架1安装与使用
线程池的使用二
The pre-sale of the new Hyundai Paristi is open, and safety and comfort are not lost