深圳网站建设开发,程序编程软件有哪些,大学生网站建设心得,网络推广顾问是干嘛的描述
请编写一个程序#xff0c;打印下面的图案#xff1a;
输入
无
输出
打印上述图案
输入样例 1
无
输出样例 1
*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*
代码一#xff08;如下#xff09;#xff1a;直接输出
#include iostream
usin…描述
请编写一个程序打印下面的图案
输入
无
输出
打印上述图案
输入样例 1
无
输出样例 1
*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*
代码一如下直接输出
#include iostream
using namespace std;
int main()
{cout * endl;cout * * * endl;cout * * * * * endl;cout * * * * * * * endl;cout * * * * * endl;cout * * * endl;cout *;return 0;
}
代码二如下采用字符数组的赋值与引用
#include iostream
using namespace std;
int main()
{char a[7][15] { {*},{*, ,*, ,*},{*, ,*, ,*, ,*, ,*},{*, ,*, ,*, ,*, ,*, ,*, ,*},{*, ,*, ,*, ,*, ,*},{*, ,*, ,*},{*} };for (int i 0; i 7; i){for (int j 0; j 15; j)cout a[i][j];cout endl;}return 0;
}
代码三如下采用字符串数组
#include iostream
#include string
using namespace std;
int main()
{string a[7] { *,* * *,* * * * *,* * * * * * *,* * * * *,* * *,* };for (int i 0; i 7; i){cout a[i];cout endl;}return 0;
}
代码四如下
#include iostream
using namespace std;
int main()
{char a[7][15];int i, j,t1;for (i 0; i 7; i){for (j 0; j t; j){if (j 0 || j % 2 0){a[i][j] *;cout a[i][j];}else{a[i][j] ;cout a[i][j];}}coutendl;if (i 2)t 4;else t - 4;}return 0;
}