https://pintia.cn/problem-sets/994805260223102976/problems/994805285812551680
虽然简单,但也要好好读题。
#include<iostream>
#include<math.h>
using namespace std;
int main() {
int col, row;
char ch;
cin >> col >> ch;
row = round(col*1.0/2);
for(int i=0; i<row; i++){
for(int j=0; j<col; j++){
if((i==0 || i==row-1) || (0<i && i<row-1 && (j==0 || j==col-1))){
cout << ch;
}else{
cout << " ";
}
}
cout << endl;
}
}
该代码实现了一个C++程序,根据用户输入的列数生成一个矩形形状的字符矩阵。矩形的行数是列数的一半,字符只在矩形的边界上打印。程序使用了for循环和条件判断来构造矩阵的边界。
&spm=1001.2101.3001.5002&articleId=114015137&d=1&t=3&u=2ff1545a1c384420a27b46703dc5d345)
382

被折叠的 条评论
为什么被折叠?



