徵羽摩柯真可爱
查看原帖
徵羽摩柯真可爱
62859
蒟蒻的蒋文轩楼主2018/8/8 09:57

【徵羽摩柯原创曲】你好,世界!【摩柯印象曲】

有人能把视频中的代码出成题目么?

代码如下(orzB站评论区大佬):

#include<iostream> 
using namespace std;
/*This is my first c++ program.
Auther:ZhiyuMoke
Date:2018.5.30
*/
void PrintDiamond(int n)
{
	int i, j;
	for (i = 0; i<n; i++)
	{
		for (j = 0; j <= n - i; j++)
			cout << " ";
		for (j = 0; j<(2 * i - 1); j++)
			cout << "*";
		cout << endl;
	}
	for (i = 0; i<n; i++)
	{
		for (j = 0; j <= i; j++)
			cout << " ";
		for (j = 0; j<(2 * (n - i) - 1); j++)
			cout << "*";
		cout << endl;
	}

}
int main()
{
	PrintDiamond(4);
	cout << "Hello World!!";
	PrintDiamond(4);
	return 0;
}

把PrintDiamond(4)改成(n) 10% n<=4; 20% n<=8; 30% n<=10; 50% n<=100; 90% n<=500; 100% n<=1000;

2018/8/8 09:57
加载中...