-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path等腰三角形的循环
52 lines (47 loc) · 932 Bytes
/
等腰三角形的循环
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
43
44
45
46
47
48
49
50
51
52
//
// main.c
// 等腰三角形循环
//
// Created by 毛遵杰 on 2019/1/6.
// Copyright © 2019 毛遵杰. All rights reserved.
//
#include <stdio.h>
int main(void)
{
int n;
printf("please enter a number");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for (int empty=1;empty<=n-i;empty++)
{
printf(" ");
}
for ( int word=1;word<=i;word++)
{
printf("*");
}
for (int word2=1;word2<=i-1;word2++)
{
printf("*");
}
printf("\n");
}
for (int i=1;i<=n;i++)
{
for (int empty=1;empty<=i;empty++)
{
printf(" ");
}
for(int word=1;word<=n-i;word++)
{
printf("*");
}
for (int word2=1;word2<=n-i-1;word2++)
{
printf("*");
}
printf("\n");
}
return 0;
}