当前位置:网站首页>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;
}
边栏推荐
- 中望3D 2023正式发布,设计仿真制造一体化缩短产品开发周期
- numpy矩阵和向量的保存与加载,以及使用保存的向量进行相似度计算
- SAP 电商云 Spartacus SSR Optimization Engine 几处 timeout 的执行顺序
- 八大排序汇总及其稳定性
- networkx绘制度分布
- 网络层重点协议——IP协议
- Selenium IDE for Selenium Automation Testing
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
- 滑窗法切分数据
- matlab as(assert dominance)
猜你喜欢

365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal

深度剖析 Apache EventMesh 云原生分布式事件驱动架构

PHP序列化:eval

IDEA can't find the Database solution

C#高级--委托

ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)

Batch大小不一定是2的n次幂!ML资深学者最新结论

Introduction to the PartImageNet Semantic Part Segmentation dataset

C#使用ComboBox控件

机器学习模型验证:被低估的重要一环
随机推荐
Grab the tail of gold, silver and silver, unlock the programmer interview "Artifact of Brushing Questions"
JSP response对象简介说明
C#中+=的用法
图像大面积缺失,也能逼真修复,新模型CM-GAN兼顾全局结构和纹理细节
PHP序列化:eval
Error: npm ERR code EPERM
IDEA连接MySQL数据库并执行SQL查询操作
sqlalchemy determines whether a field of type array has at least one consistent data with an array
报错IDEA Terminated with exit code 1
【牛客刷题-SQL大厂面试真题】NO3.电商场景(某东商城)
清除浮动的四种方式及其原理理解
SAP 电商云 Spartacus SSR Optimization Engine 几处 timeout 的执行顺序
NameNode (NN) and SecondaryNameNode (2NN) working mechanism
文本相似度计算(中英文)详解实战
matlab as(assert dominance)
ERROR 1819 (HY000) Your password does not satisfy the current policy requirements
战略进攻能力的重要性,要远远高于战略防守能力
Install the latest pytorch gpu version
mysql8, starttime的下一个值作为endtime的上一个值?
Verilog——基于FPGA的贪吃蛇游戏(VGA显示)