網站首頁 編程語言 正文
主要是用for循環來寫九九乘法表
1.左下角
#include <stdio.h>
int main()
{
int i, j;
for (i = 1; i < 10; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d*%d=%-3d ", j, i, i * j);
}
printf("\n");
}
return 0;
}
2.等腰三角形
#include <stdio.h>
int main()
{
int a = 0, b = 0, c = 0;
for (a = 9; a >= 1; a--)
{
for (c = 0; c <= (8 - a) * 4; c++)
{
printf(" ");
}
for (b = 1; b <= a; b++)
printf("%d*%d=%2d ", a, b, a * b);
printf("\n\n");
}
return 0;
}
3.左上角
#include <stdio.h>
int main()
{
int i = 0, j = 0;
for (i = 9; i >= 1; i--)
{
for (j = 1; j <= i; j++)
printf("%d*%d=%-3d ", i, j, i * j);
printf("\n");
}
return 0;
}
4.右上角
#include <stdio.h>
int main()
{
int i, j;
for (i = 9; i > 0; i--)
{
for (j = 9; j > 0; j--)
{
if (i < j)
printf("\t");
else
printf("%d*%d=%2d ", j, i, i * j);
}
printf("\n");
}
return 0;
}
5.右下角
#include <stdio.h>
int main()
{
int i = 0, j = 0;
for (i = 1; i < 10; i++)
{
for (j = 9; j > 0; j--)
{
if (i >= j)
printf("%d*%d=%-3d ", i, j, i * j);
else
printf("\t");
}
printf("\n");
}
return 0;
}
原文鏈接:https://blog.csdn.net/qq_44394562/article/details/125919155
相關推薦
- 2024-02-16 SpringBoot的默認組件掃描
- 2022-05-13 Django-Rest framwork框架 序列化與反序列化
- 2022-10-12 字節封裝React組件手機號自動校驗格式FormItem_React
- 2022-09-09 Go語言中defer語句的用法_Golang
- 2023-12-19 CentOS和Ubuntu中防火墻相關命令
- 2022-10-19 C++模板編程特性之移動語義_C 語言
- 2022-05-20 Spring注入bean的常用的六種方式
- 2022-07-15 python新手練習實例之萬年歷_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支