Re: [問題] 打星號畫圖

看板C_and_CPP作者 (Alien)時間15年前 (2009/11/05 02:35), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串10/12 (看更多)
※ 引述《elfkiller (沒有暱稱)》之銘言: : #define TotalStarNumber 6 : int j=1,k=2; : for(int i=1;i<=TotalStarNumber;++i){ : cout<<'*'; : if(i==j){ : cout<<endl; : j+=k; : ++k; : } : } 另一種類似的玩法 (這個是由 1顆 印至 n 顆) printStars(int levels) { for (i = 1, currentLevel = 1; currentLevel < levels; ) { printf("*"); ++i; if ( i > currentLevel) { printf("\n"); currentLevel++; i = 1; } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 202.155.236.82
文章代碼(AID): #1AyZdRml (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1AyZdRml (C_and_CPP)