5 条题解
-
1
要是不写函数就太麻烦、太乱了,还是用函数好一点~
已AC,请放心食用
#include <iostream> using namespace std; void squ(int n) { for (int i = 1; i <= n; i++) { cout << "*"; } cout << endl; } void are(int n) { for (int i = 1; i <= n - 2; i++) { cout << "*"; for (int j = 1; j <= n - 2; j++) { cout << " "; } cout << "*" << endl; } } int main() { int n; cin >> n; squ(n); are(n); squ(n); return 0; }
养成好习惯,看后点个赞😎!
-
1
AC Code
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cout << "*"; cout << endl; for (int i = 1; i <= n - 2; i++) { for (int j = 1; j <= n; j++) { if (j == 1 || j == n) cout << "*"; else cout << " "; } cout << endl; } for (int i = 1; i <= n; i++) cout << "*"; return 0; }
- 1
信息
- ID
- 489
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 2
- 标签
- 递交数
- 140
- 已通过
- 86
- 上传者