Re: [問題] 請問有誰會寫DEV-c++的程式

看板C_Sharp作者 (許我個女性友達吧:))時間19年前 (2004/12/07 00:02), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/7 (看更多)
※ 引述《pyngtzann.bbs@micro.bio.ncue.edu.tw (好累的恩....)》之銘言: : ※ 引述《libery.bbs@ptt.cc (許我個女性友達吧:))》之銘言: : > int total = 0; : > int reverse = 1; : > for(int i = 1 ; i <= N ; i++) : > { : > total += reverse*i; : > reverse *= (-1); : > } : > print(total); : 程式少列印出1-2+3-4+5-6...........N : 但總total已經算出 int total = 0; int reverse = 1; String sequence = ""; for(int i = 1 ; i <= N ; i++) { sequence += i; total += reverse*i; reverse *= (-1); if(reverse > 0) sequence += "+"; else if(reverse < 0) sequence += "-"; else if(i == N) sequence += "="; } sequence += total; print(sequence); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.104.237.57
文章代碼(AID): #11j8AHG2 (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #11j8AHG2 (C_Sharp)