Re: [問題] 關於畫三角形
自己參考別人也寫了一個方法,但感覺用到好多迴圈與變數,是否還有更有效率的方法呢
?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int high=0,temp,x=0;
printf("Input tringle high = ");
scanf("%d",&high);
temp=high;
for(int i=0;i<high;i++)
{
for(int space=0;space<temp-1;space++)
{
printf(" ");
}
for(int start=0;start<=x;start++)
{
printf("*");
}
x+=2;
temp-=1;
printf("\n");
}
system("pause");
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.219.207
→
11/06 14:47, , 1F
11/06 14:47, 1F
→
11/06 16:14, , 2F
11/06 16:14, 2F
討論串 (同標題文章)