当前位置:网站首页>C语言基础练(九九乘法表)与打印不同星号图案
C语言基础练(九九乘法表)与打印不同星号图案
2022-07-31 13:24: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);//要打印平行四边形的行数
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);//打印等腰三角形的行数
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;
}
打印顶角朝下的等腰三角形
#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;
}
边栏推荐
- 深入浅出边缘云 | 4. 生命周期管理
- 模拟量差分和单端(iou计算方法)
- C#使用NumericUpDown控件
- selenium被反爬了怎么办?
- P5019 [NOIP2018 提高组] 铺设道路
- ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
- 技能大赛训练题:登录安全加固
- Reasons and solutions for Invalid bound statement (not found)
- IDEA版Postman插件Restful Fast Request,细节到位,功能好用
- ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
猜你喜欢

networkx绘制度分布

golang-gin-优雅重启

go使用makefile脚本编译应用

PyQt5 rapid development and actual combat 10.1 Get city weather forecast

代码随想录笔记_哈希_454四数相加II

Solution for browser hijacking by hao360

报错:npm ERR code EPERM

ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your

百度网盘安装在c盘显示系统权限限制的解决方法

C#高级--委托
随机推荐
CLion用于STM32开发
Golang - gin - pprof - use and safety
golang-gin-优雅重启
EXCEL如何快速拆分合并单元格数据
Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
SAP message TK 248 solved
golang-gin-pprof-使用以及安全问题
Edge Cloud Explained in Simple Depth | 4. Lifecycle Management
知名无人驾驶公司:文远知行内推
A detailed explanation of the usage of Async and Await in C#
最新完整代码:使用word2vec预训练模型进行增量训练(两种保存方式对应的两种加载方式)适用gensim各种版本
Spark学习:为Spark Sql添加自定义优化规则
The importance of strategic offensive capability is much higher than strategic defensive capability
网络协议及相关技术详解
战略进攻能力的重要性,要远远高于战略防守能力
golang中使用泛型
C#中+=的用法
Selenium IDE for Selenium Automation Testing
Selenium自动化测试之Selenium IDE
八大排序汇总及其稳定性