討論串[問題] 想請問一題 For迴圈的應用,印圖形
共 7 篇文章
首頁
上一頁
1
2
下一頁
尾頁

推噓3(3推 0噓 2→)留言5則,0人參與, 最新作者bleed1979 (十三)時間14年前 (2011/10/21 05:51), 編輯資訊
0
0
0
內容預覽:
我修改一下題目好了。. *. **. ***. ..... ..... 到第50個*. 49個*. .... .... **. *. 原po的是 5 個,我改為50個。. 只能有一個for,和這個for唯一一個條件判斷式,除此之外不能有條件判斷式。. 只能include <stdio.h>. 可以讓
(還有215個字)

推噓1(1推 0噓 8→)留言9則,0人參與, 最新作者adrianshum (Alien)時間14年前 (2011/10/21 00:21), 編輯資訊
0
0
0
內容預覽:
psuedocode:. printTriangle(int height) {. char* s = malloc(height + 1);. memset(s, height, '*');. s[height] = '\0'; //弄一條 height 個長的 string, 裡面全是*. fo
(還有218個字)

推噓0(0推 0噓 2→)留言2則,0人參與, 最新作者tarrytu (LASK)時間14年前 (2011/10/21 00:09), 編輯資訊
0
0
0
內容預覽:
以前不知道在哪看到的方法. for(int i = -4 ; i <5 ; i++){. for(int j =0 ; j < 5-abs(i) ; j++). putc('*',stdout);. putc('\n',stdout);. }. --. 發信站: 批踢踢實業坊(ptt.cc).

推噓1(1推 0噓 1→)留言2則,0人參與, 最新作者adrianshum (Alien)時間14年前 (2011/10/21 00:08), 編輯資訊
0
0
0
內容預覽:
倒不如這樣寫. for (int i =0; i == 0; i++) {. printf("*\n**\n***\n****\n*****\n****\n***\n**\n*");. }. // 要兩個 for? 多加一個 for (;0;); 就好了. --. 發信站: 批踢踢實業坊(ptt

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者kason (kason)時間14年前 (2011/10/20 22:58), 編輯資訊
0
0
0
內容預覽:
for(i=1; i<=9; i++){. for(j=0; j<i && j<10-i; j++). printf("*");. printf("\n");. }. (把判斷式放在for裡面 就不算if了吧XD). --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From: 219.84
首頁
上一頁
1
2
下一頁
尾頁