酷代码 AI
菜单

#include <iostream> using namespace std; int main() { int n; // 读取输入的矩阵行数和列数 cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j == 0 || j == n - 1) { // 每行的第一个和最后一个位置输出金色小行星 cout << '#'; } else { // 其他位置输出普通小行星 cout << '*'; } } // 每行输出结束后换行 cout << endl; } return 0; } 去除备注

#include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j == 0 || j == n - 1) { cout << '#'; } else { cout << '*'; } } cout << endl; } return 0; } [2026-01-31 19:59:37 | AI问答 | 116点数解答]

服务商
相关提问
发财导航,免费问AI
实用工具查看更多