0 like 0 dislike
6.1k 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
| 6.1k views
0 0
Called for Help
0 0
Called for Help

45 Answers

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

main()

{
* ** * * ** *** ** ** i,a,b,c;
** * ** ** * ** * ****** * * **
* * **** ** ** ** * * ** ** *

{
* * * * * * ** * ** ** ** *** ** *

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

}
* * * ** ** ***

{
* * * ** * * ******* ** *

{
* ** * * ** ** * * * ********

}

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



}


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







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

int main()

{

   int num;
* * * *** * * ** ***** * * * *** * &num);
***** * ***** * * * i = 1;i <= num;i=i+2)

   {
** * * * ** * **** * ** * * ***** ******* ** ** ** * * * ");
* ** * * * *** * * * * * *** ** * * ** ***** \n");
* ** *** * ********** **** * *** *** **** k =1;k<=num-(i/2);k++)
*** ** * ** *** * ** * ** * * * *
* * ** * ** * * * *** * ***** ** *** ** * **** * * * ** ");
*** * * **** * ** ** * *** *
* *** *** ** ** ***** * *** **** * *** ** **** * ** ** *** ** *
** * ***** ** ***** * **** ***** * * *** * j = 1;j <= i;j++)
* * ** ** ***** * * ** * ** *
*** ** * ** * ** *** ** *** * * * ** * * * * * * * **** ***** *  
*** ** *** *** **** * ** * **** ** * * * ***** ** **** * ** * * * * * ** * * ***** * * * ***** * *** * *** ** * ***** * * ** ***** * * ** ** ***** ** * ** * *** **
** * ** * * * * *

   return 0;

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

#include<stdlib.h>

int main()

{
** * ** * *** * ** ** ****** ** a, b, i;
* *** ** * ** ******* * * ** ** *
* * ** * * * * * * ** *** ** * * ***
* * *** ** * * **** *
****** ** * * *** * ** * * * ** **** ***** * **** * *****
*** ** * *** ** * ** ** * * ** * ** * ** *** * ");
* ****** * * * * * * ** ** * * *** * ** * * * ** ** ****
** ** *** *** * * ** *** *********** ** ** **** * **
* ** ********* * *** **** * * **** * * ** *** * ** ****
****** * **** * ****
** * ** * * ** *** * **** **** * **** *
* * * *** *** ** * 0;
* *** * *** * * * ** ***
*** ** * *** ** * *
** * * * * ** * *

    

    

    

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



int ****

{
* a, j, k;
*** * ** * * ***
** = 1;j ******* a / 2 + 1;j ++)

{
* * * *** * * *** *** ** = 0;k ** a / 2 - j +1;k ++)
*** * ** ** * * * * * * ** ***** ***
* ****** * **** ** ** ***** = 0;k **** * 2 + 1 ;k ++)
** ** * * *** *** * * ** * * **
** * *** * *** * ** * * * * * *

}

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

#include * * * *



int main()

{
* ** ** ** * * * **** x,y,z;
* * * * * * * ** * * * * ** * **
** **** *** * * = 1;x <= (z+1)/2;x ++)
* * *** * ** * *
****** * * ** * * * * ** = 1;y <= (z+1)/2 - x;y ++)
* * * *** ** ** ** *** * * * * * *** *** * *** ** * * ");
* * ** * *** * ********* * ** *** = 1;y <= (x*2)-1 ;y ++)
* * ** ** * *** * *** * * * * *** * ** ** * ** ***** * * * *
** * * * * ** * * * ** * * ** * * * ** **
** * *** * * * * * ** *


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

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

#include * * ** ** *



int main()

{

int a, j, k;
* * * ** ** * * * **
*** *** * * * / 2+1; j++)

{
* ** ** * * ** * **** ******* *** a/2 -j +1;k++)
** * * ** * * ** * * ** ** *** * ** *****
** *** * ***** *** * * **** ** *
* **** ** * * ** ** * * * * ** *

}

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

#include <stdlib.h>



int main()

{

int a,j,k;

scanf("%d",&a);

for(j=1;j<=a/2+1;j++)
* * *** *** **** ** * **** * * ***** * * * ***** * ** ** * * ** *** ***** **** ** * * * *** ** * ** * * ** *
* **** * * * * * * * * ****** **** * ** * ** *** * *** **** ** * * ** ** ** *** * * * * ** * ** * ** * ** *** ** *** **** *** **
** * * **** ***** * *** ** ** ** *** * * * * **** ** * * ** * * *** * * ** **** * * ***** * * * * * * ** * ** * * * ** * * ");
* * * * * * * ***** ** **** * * * *** ** * * ** * ** * * ****** ** ****** * * ** ** * * * * * **** *** ** * **** * * * **** ** * * * *** ** *
** * *** **** *** * ***** * ** ** *** *** * ***** * ** ** * * * ** ** *** ***** *** * ** ** ** * * * ** * ** * **** * *
* * * * * * * * * * ** * ** *** * * ** * **** * * * ** ** ** * ****** * **** ** ** **** **** * ** * * * * ** * *
*** * *** *** * * * ** ** * * * ** * * ** * * * * * * * * ** * * * **** *** *** * ** ** ****** **** * ** *

system("pause");

return 0;

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

#include *** * * * * * **



int main()

{
* ** * * * ** ** * * * * num, n, p;
* * ** * * *** ***** *** **** * ***** &num);
* * ** ** * * ** *** *** **** (n = 0; (2 * n) + 1 <= num; n++)
* * * ** ** * ***
* * ** ** *** * * * * ** * **** * ** * * (p = 0; p <= (num / 2) - n - 1; p++)
** * ***** ** ** ** ** *** * **** * ****** * * ** **** * ** *** * * * **** ");
** *** * * ***** * *** ****** ** *** * * (p = 0; p <= (n*2); p++)
* *** **** ** * * * ***** ****** *** *** * * * ** ** * * * * * * * * *** * * * ** **
** * * * * *** *** ** * ** *** *** * *** ** **** * * * *** * *
* * * ******* *


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

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



int main()

{
**** * ***** * ** ****** * ** a, b, c;
** **** ** * **** * ***** *** ** **** ** *
***** * ** **** * * * c <= a; c+=2)
* * *** ** ** ***
*** ** * * * * ** * ****** * * b <= (a-c)/2; b++)
* *** * ** * * *** ****** * ****** * * ");
* * ** ** * * ** ***** ** * * * b <= c; b++)
** * * ** * * * * * ** **** * ** * * **** *
** * * ** * * * * ** * ** *** * * * * *
******* * * * ** ** **
****** * ******* ** * * 0;

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

#include <stdlib.h>





int main()

{
*** ** *** * * ** * a ;
** ** *** * * i , j ;

    
***** * * ** * ** *** ** **** * * * *** &a);


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

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


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

    }

   

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

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

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
| 3.7k 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
| 8k 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
| 5.5k 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
| 7.2k 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
| 4.6k views
12,783 questions
183,442 answers
172,219 comments
4,824 users