admin管理员组

文章数量:1530023

2024年6月21日发(作者:)

扣丁学堂C语言 星星的实现

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

// ConApp2_ : 定义控制台应用程序的入口点。

//

#include "stdafx.h"

#include "iostream"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

int num;

cout << "请输入星星行数:";

cin >> num;

for (int i = 1; i <= num; i++)

{

for (int j = 1; j <= num - i;j++)

{

cout << " ";

}

for (int k = 1; k <= i * 2 - 1;k++)

{

cout << "*";

}

cout << endl;

}

num--;

for (int i = num; i >= 1; i--)

{

for (int j = 0; j <= num - i; j++)

{

cout << " ";

}

for (int k = 1; k <= i * 2 - 1;k++)

{

cout << "*";

}

cout << endl;

}

cout << endl;

cout << endl;

return 0;

43 }

本文标签: C语言实现控制台