解题思路:这题有点恶心,需要判断输入大于0,不看别人的题解我还没发现
注意事项:
参考代码:
#include<bits/stdc++.h>
using namespace std;
int h, w;
int main() {
ios::sync_with_stdio(false);
cin >> h >> w;
if (h > 0 && w > 0) {
for (int i = 1; i <= 2 * h + 1; i++)
{
for (int j = 1; j <= 2 * w + 1; j++)
{
if (i % 2) {
if (j % 2)cout << "+";
else cout << "-";
}
else
{
if (j % 2)cout << "|";
else cout << " ";
}
}
cout << endl;
}
}
return 0;
}
0.0分
2 人评分
【亲和数】 (C语言代码)浏览:536 |
小明A+B (C语言代码)浏览:1246 |
数组输出 (C语言代码)错误???浏览:558 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:749 |
WU-蓝桥杯算法提高VIP-交换Easy (C++代码)浏览:1107 |
【金明的预算方案】 (C++代码)浏览:934 |
C语言程序设计教程(第三版)课后习题6.8 (C++代码)浏览:575 |
整除问题 (C语言代码)浏览:518 |
多输入输出练习2 (C语言代码)浏览:1654 |
判定字符位置 (C++代码)浏览:666 |