为什么只有60,求佬
查看原帖
为什么只有60,求佬
955590
youjiangning楼主2023/3/5 15:18
#include<iostream>
using namespace std;
int main() {
	while (1) {
		int num = 0;
		cin >> num;
		int arr[10][10];
		int arr2[10][10] = { 0 };
		for (int i = 0; i <= num; i++) {//第一个矩阵赋值
			for (int j = 0; j <= num; j++) {
				arr[i][j] = i * num + j + 1;
			}
		}
		int number = 1;
		for (int i = 0; i < num; i++) {//第二个矩阵赋值
			for (int j = i; j >= 0; j--) {
				arr2[i][num - j - 1] = number++;
			}
		}
		for (int i = 0; i < num; i++) {//第一个矩阵输出
			for (int j = 0; j < num; j++) {
				if (arr[i][j] < 10 && num>3) {
					cout << "0" << arr[i][j];
				}
				else {
					cout << arr[i][j];
				}
			}
			cout << "\n";
		}
		cout << "\n";
		for (int i = 0; i < num; i++) {//第二个矩阵输出
			for (int j = 0; j < num; j++) {
				if (number < 10) {
					if (arr2[i][j] == 0) {
						cout << " ";
					}
					else {
						cout << arr2[i][j];
					}
				}
				else {
					if (arr2[i][j] == 0) {
						cout << "  ";
					}
					else if (arr2[i][j] < 10) {
						cout << "0" << arr2[i][j];
					}
					else {
						cout << arr2[i][j];
					}
				}
			}
			cout << "\n";
		}
	}
}
2023/3/5 15:18
加载中...