文章
19
粉丝
0
获赞
125
访问
2.9k
#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 <= 2 * i - 1; j ++) {
cout << "*";
}
for(int j = 0; j < 2 * i - 2; j ++) cout << " ";
cout << endl;
}
for(int i = n - 1; i >= 1; i --) {
for(int j = 2 * i - 1; j >= 1; j --) {
cout << "*";
}
for(int j = 2 * i - 2; j >= 0; j --) cout << " ";
cout << endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, cnt;
cin >> n;
while(n --) {
cin >> cnt;
int num = 0;
for(int i = 1; i <= cnt; i++) {
for(int j = 1; j <= 2 * i - 1; j ++) {
num ++;
}
}
for(int i = cnt - 1; i >= 1; i --) {
for(int j = 2 * i - 1; j >= 1; j --) {
num ++;
}
}
cout << num << endl...
登录后发布评论
暂无评论,来抢沙发