0 like 0 dislike
7.8k views
請設計一個程式,利用迴圈輸出文字金字塔。

p.s. 輸入皆為奇數,且不大於20

範例輸入1:

5

範例輸出1:

  *

 ***

*****

輸入範例2:

7

輸出範例2:

   *

  ***

 *****

*******
[Exercise] Coding (C) - asked in 作業 by (18k points)
ID: 13501 - Available when: Unlimited - Due to: Unlimited
| 7.8k views
0 0
Called for Help
0 0
Called for Help

45 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

int main()

{
* * **** ** * * ** n=0,i=0,j=0,;
* * ** * ** * **** * * **** **** **

    
* *** * *** * * ** ** * ** * **

    {
* *** * ** ** * ***** ** * * ****** *** ** * ** ****
** *** * * ** * ** ** ** * ** **** * ");
* ** ** * * ** * **** ** * ** * * ******** * * ** * **
* * **** * * * ** * ** * ** *** ** ***** * * ** *
** * ** * * * * ***** * * ** ** **** *** * * ** * * ***
* * ** ** ** * * *** *
** **** * ** * * *** ** ******* *** *
* * ** * **** * * ** *** * * 0;

}
answered by (156 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>



int main()



{

    int x=0,y=0,z=0;

    
* * ** *** ** ** ** * * * * * ***

    
* ** *** ****** * *** *** *** *

    {
**** ** * **** ** * * *** * * * * ** ******** * ** ** ***** * * *** * * **** * * * * * ** ** ** * * **** *** *** ** *** *** * * *** ** * **** * * ****
* ** ** * * ********* * * * * * * * * * * * ** ** * * ** ** **** *** **** * ** * * * * * * * ***** ******** * ** * ** *** ** * ** * * *** * ");
******** * * * * * * ** * ** ** ** * * * ** *** * ** * ** * ** **** ***** *** * * *** *** ** ** ******* *** *** ** ** * * *** ** * ** *** *** *
* * * * *** * * * *** * * ** * * * *** * **** * ** ** ****** * *** ** ** ***** * * **** ** * * * *** * * ** *** * * ** *** * * * *** *
***** *** * ** * ** * * ** * *** *** *

    }
** ** *** * * ** ** * ** ** **** * * *** *** * *** ********* **** ** * * * * * *** ****** * * *** **** ** ** * **** * * *

    
**** * * * *** * ** ** ** * *****
* * ***** * ** * * 0;

}
answered by (122 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

int main()

{
* ** ** * * * ** * *** ** n=0,i=0,j=0,z=0;
* * ******* * *** * * * * *** ** * * * **

    
** * * * * ***** **** * *** ***** * *

    {
* * * ** ****** ** * *** * ** *** ** * * * * **
**** *** *** * * ** * ** ******** ** * * *** ** ");
* * * ** ****** *** **** ** ** ** * ** ******* ** ** * * * ** ** * *
** *** ** * * * * ** * *** ** ** ** * ** *
**** * *** ** *** * * ** ***** ** *** * ** ****
* *** * * **** * *
* ** * ***** * * * * *** ** *
* * * * * ** ** ** ** 0;

}
answered by (156 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main (void)

{
* **** * **** * a=0,
* *** * ** ******** * ****** * * * * * *
* * ***** * ** *** *** * * *** *** * *
** *** * * * * ** **** *** ***** * ** * *

    
***** * ** * * ** ** **** * ** **
******* * **** *** ** *
* * *** ******* * ** * * **

    {
*** * * **** *** * * * * **** * * **
* * ** ** * * * *** ****** *** ");
* * * ** ***** ** * ** * * *
* * ****** * * *** * * * ** * ** *** *** **
****** * * * * * *** *** * * * * ** * **
* * * ** * *** * *** ***
** * * * * ***** * * * ** ** *** ** * **
* ** * * ***** **** **** 0;

}
answered by (-170 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

int main()

{

    
*** ** * *** * * * * ** n;
* ** ** ** ** * ** *** * * i,k,j;
* * **** ** ** * * * ** * * **** * ** &n);
** ** * * ** * * * ** * **** ****
*** ** * ***** ** *** (i=1; i <= n; i=i+2)
****** * * ** * ** ** **
*** ** ** * * ***** *** *** ** * ** ****** ***** ** k>0; k--)
* *** ** ******* * * * *** ** ** ** * * * ** * * ");
**** * * * ** * * * ** * ** **** * * * *
* ** ** ** * * * *** * ** * * *** * * * * j<=i; j++)
*** * * * * * **** * ****** * ** * ** * * ****** ** ** * **
* * * *** ****** *** **** **** * * *** * *
* *** *** * *** ** *** * *** *** ** * * * if(i!=n)
*** ** * *** ** * ** * **** ** ** **** ** * * ** ** **** *** *****
* * * ** * * * * **   
*** * ** * ** *** * *** * * ** * * * * * * **
** * ** * * ** * *** *** ** * ** **
*** * * *** *** ** ** ***** 0;

}
answered by (-110 points)
0 like 0 dislike
Hidden content!
#include **** *** *

#include * * *****



int main()

{

int i,j,sum,n;


* * ** * ** ** *** **


** ***** * = 1;i <= sum;i += 2)
* *** * ** ***
* * ******* ** * *** ** = 1;n <= ((sum-i)/ 2);n++)
***** * * * ***** **** * *****
** *** ** **** ** ** *
* * * ** **** *** ** = 1;j <= i; j++ )
** * * ** ** ** * ** ** * **** ****
* * ** ** *** * * * * * * *
* * * *** **** * *** *** ** *** *

** *** ** * *** ** * ** ** *** * **


* * *** * * ***


** * ******* * *** ** *** *


** ** * *** * 0;

}
answered by (-186 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

int main()

{
* *** * ** * * * k = 0 , n , space , star , h ;

    
* ** * *** ******** * * **** **** * ** * *
** ** ***** * **** ** * h = (n/2 + 1) ; h > 0 ; h-- )
**** ** * * ** * ** * *
*** * * * ** * *** ** * **** *** ****** **** *
* **** **** * ****** *** * * ** ** * ** ** * ***
***** * * ** ** ** ** * ** * * *** * **** * * * space = n / 2 ; space > 0 ; space-- )
* * ** * *** ** *** * *** ** * **** * * ** ** * * * * * ** * * ");
***** **** * * * * * ** ** * ** ***** ******** ** ** * star = k + 1 ; star > 0 ; star-- )
*** ***** * *** * ** ** * ** ** * * ** * ** ** ** * * ** * * * **
* * ** **** *** ** * **** * * * * * ** ** ** * ** * **
* *** **** * ** *** *** * *** ** * * ** ** * = n - 2 ;
***** ** * * *** *** ** * **** *** ******** * *** = k + 2 ;
** **** **** * * ***
* * * * ***** ** ********** * * *********
** * * ** *** ** * ** 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
** ***** * **** **
* ** *** * *** *



int main()

{
** * * * ** ****** * ** * a = 0,i,j,k;
* * *** ** *** * ** ** *
* ** ** *** ** * * ** * ** ** * *

   
* ** * ******* = 1;i <= a;i += 2)
** **** * *** ** ** = 1;k <= ((a-i)/2);k++)
* ***** * * *** *** * ");
* * * * * **
*** ******** ** * *** = 1;j <= i;j++)
** * ** * * * * * * ** * * *
* ** * ** * *
* * * **** * ***
****** ** * ****
**** *** **** * ** ** ** ******* ** *
*** * * ** *** **** ** * 0;

}
answered by (-264 points)
0 like 0 dislike
Hidden content!
* * * * * ***
* ** * * **** * ****



int main()

{
** *** ****** ***** **** a = 0,i,j,k;
** ****** **** ** * ** *
* * ** * * * * **** ** * * * * *** ****** **

   
**** *** * ** * = 1;i <= a;i += 2)
* * * **** **** ***
* * * * ** ** ***** = 1;k <= ((a-i)/2);k++)
* *** **** ** * ** * * ** * * ");
* ** **** ***
* *** ** * *** * * = 1;j < i;j++)
* *** * * ** ** * *** * * * **
*** ** **** ******
* * * ** * * ** * * * ** *** ***
* * *** *** * ** * *****
* ** * * * ******* ******* * *** * *
***** ** ** * ** * * * 0;

}
answered by (-264 points)
0 like 0 dislike
Hidden content!
* * ** * * * **
***** * * *



int main()

{
* ** ** ** ** ** * * a = 0,i,j,k;
*** * **** *** *
*** * * *** **** **** * * **** * * ** *

   
* * ** ******* *** = 1;i <= a;i += 2)
* ****** ** **
** * * ** **** = 0;k <= (a-i)/2;k++)
**** **** * * * ** ");
**** * ** *** *
* * ** * *** *** ** = 0;j < i;j++)
* * *** * ** ** ** ** ** *** * *
******* *****
* * ** ** ** ******* ****** *
* ** * ****** * * **
*** * * ** **** ******* ***** **
** * ****** * *** ** * ** * 0;

}
answered by (-264 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.94
©2016-2026

Related questions

0 like 0 dislike
23 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13528 - Available when: Unlimited - Due to: Unlimited
| 4.8k views
0 like 0 dislike
67 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13427 - Available when: Unlimited - Due to: Unlimited
| 10.2k views
0 like 0 dislike
40 answers
[Exercise] Coding (C) - asked Sep 29, 2016 in 作業 by Shun-Po (18k points)
ID: 11795 - Available when: Unlimited - Due to: Unlimited
| 6.9k views
0 like 0 dislike
60 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 13428 - Available when: Unlimited - Due to: Unlimited
| 9.1k views
0 like 0 dislike
31 answers
[Exercise] Essay (Open question) - asked Nov 3, 2016 in 作業 by Shun-Po (18k points)
ID: 16958 - Available when: Unlimited - Due to: Unlimited
| 6k views
12,783 questions
183,442 answers
172,219 comments
4,824 users