-
Notifications
You must be signed in to change notification settings - Fork 18
/
6_18乘法表格式化输出.cpp
66 lines (62 loc) · 1.24 KB
/
6_18乘法表格式化输出.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
//习题6_18
//乘法表
int main(){
int i,j;
//第一种
for (i = 1;i < 10;i++)
printf("%d\t",i);
cout << endl;
for (i = 1;i < 10;i++)
printf("-\t");
cout << endl;
for (i = 1;i < 10;i++){
for (j = 1;j < 10;j++){
printf("%d\t",i*j);
}
cout << endl;
}
cout << endl;
cout << endl;
//第二种
for (i = 1;i < 10;i++)
printf("%d\t",i);
cout << endl;
for (i = 1;i < 10;i++)
printf("-\t");
cout << endl;
for (i = 1;i < 10;i++){
for (j = 1;j < 10;j++){
if (j<=i)
printf("%d\t",i*j);
else
printf(" \t");
}
cout << endl;
}
cout << endl;
cout << endl;
//第三种
for (i = 1;i < 10;i++)
printf("%d\t",i);
cout << endl;
for (i = 1;i < 10;i++)
printf("-\t");
cout << endl;
for (i = 1;i < 10;i++){
for (j = 1;j < 10;j++){
if (j>=i)
printf("%d\t",i*j);
else
printf(" \t");
}
cout << endl;
}
return 0;
}