java99乘法表正倒三角
时间: 2024-05-17 08:10:10 浏览: 15
Java99乘法表正倒三角的代码如下:
正三角:
```
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
System.out.print(j+"*"+i+"="+i*j+" ");
}
System.out.println();
}
```
倒三角:
```
for(int i=9;i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print(j+"*"+i+"="+i*j+" ");
}
System.out.println();
}
```
相关问题
c语言99乘法表正倒三角
以下是C语言中打印九九乘法表正倒三角的代码示例:
正三角靠右:
```c
#include <stdio.h>
int main() {
int a, n, b;
printf("正三角靠右:\n\n");
for (a = 1; a < 10; a++) {
for (n = 9; n > a; n--) {
printf(" ");
}
for (b = 1; b <= a; b++) {
printf("%d*%d=%2d\t", a, b, a * b);
}
printf("\n");
}
return 0;
}
```
倒三角靠右:
```c
#include <stdio.h>
int main() {
int a, n, b;
printf("倒三角靠右:\n\n");
for (a = 1; a < 10; a++) {
for (n = 1; n < a; n++) {
printf(" ");
}
for (b = 9; b >= a; b--) {
printf("%d*%d=%2d\t", a, b, a * b);
}
printf("\n");
}
return 0;
}
```
以上代码可以在C语言中打印出九九乘法表的正倒三角形式。
#### 引用[.reference_title]
- *1* [c语言:九九乘法表 | 正三角形 | 倒三角形](https://blog.csdn.net/xinanbo/article/details/113175807)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [C语言中的输出99乘法表4种方法](https://blog.csdn.net/qq_43178535/article/details/126963299)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
java九九乘法表倒三角
以下是Java代码实现九九乘法表倒三角:
```
public class Main {
public static void main(String[] args) {
for (int i = 9; i >= 1; i--) {
for (int j = 9; j >= i; j--) {
System.out.print(j + "*" + i + "=" + (i * j) + "\t");
}
System.out.println();
}
}
}
```
输出结果为:
```
9*9=81
9*8=72 8*8=64
9*7=63 8*7=56 7*7=49
9*6=54 8*6=48 7*6=42 6*6=36
9*5=45 8*5=40 7*5=35 6*5=30 5*5=25
9*4=36 8*4=32 7*4=28 6*4=24 5*4=20 4*4=16
9*3=27 8*3=24 7*3=21 6*3=18 5*3=15 4*3=12 3*3=9
9*2=18 8*2=16 7*2=14 6*2=12 5*2=10 4*2=8 3*2=6 2*2=4
9*1=9 8*1=8 7*1=7 6*1=6 5*1=5 4*1=4 3*1=3 2*1=2 1*1=1
```
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)