You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
707 B
31 lines
707 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
//第一种方式打印正方形
|
|
for (int i = 1; i <= n; i++) {
|
|
for (int j = 1; j <= n; ++j)
|
|
printf("%02d", (i - 1) * n + j);
|
|
printf("\n");
|
|
}
|
|
printf("\n");
|
|
|
|
//第二种方式打印正方形
|
|
// for (int i = 1; i <= n * n; i++) {
|
|
// printf("%02d", i);
|
|
// if (i % 4 == 0) printf("\n");
|
|
// }
|
|
|
|
int num = 1;
|
|
for (int i = 1; i <= n; i++) {
|
|
for (int j = 1; j <= n - i; j++)
|
|
printf(" ");
|
|
for (int j = 1; j <= i; j++)
|
|
printf("%02d", num++);
|
|
printf("\n");
|
|
}
|
|
return 0;
|
|
} |