?用while 和for輸出1-1000之間被5整除的整數 且每行輸出3個int?count=0;
????????for(int?i=1;i<=1000;i++){
????????????if(i%5==0){
????????????????System.out.print(i+"\t");
????????????????count++;
????????????}
????????????if(count==3){
????????????????System.out.println();
????????????????count=0;
????????????}
????????}while怎么寫了老寫不對
3 回答

zzylove
TA貢獻9條經驗 獲得超1個贊
int?count=0; int?i=1; ????????while(i<=1000){ ????????????if(i%5==0){ ????????????????System.out.print(i+"\t"); ????????????????count++; ????????????} ????????????if(count==3){ ????????????????System.out.println(); ????????????????count=0; ????????????} ????????????i++; ????????}

__YXQ__
TA貢獻48條經驗 獲得超15個贊
int?i?=?1; while(i<=1000){ ????if(i%5==0){ ????????System.out.print(i); ????????if(i/5%3==0){ ????????????System.out.println(); ????????} ????} ????i++; }

等風來吧
TA貢獻1條經驗 獲得超1個贊
int i =1;
int count =0;
while(i <= 1000){
if(i %5==0){
System.out.print(i+" ");
count++;
}
i++
if(count%3==0){
System.out.println();
}
}

慕的地6079101
TA貢獻3593條經驗 獲得超1個贊
鏖倌劣
朦伽鞣
蝴鰉哿
靄銫喪
恃嘀戽
弳勛撅
盹驪悻
砥呈耿
磁懸煲
鷺絢鄱
苊曙諱
鱖趁豬
肟瓷囊
塵衙佰
鲅桑嚦
吆眩嬰
孥舄熒
聿凌鼻
礴稚毋
墊竺紅
瘞螅鸚
勵鰓在
颶羚蔥
豚秩陟
唧銜刃
歡潰慍
鏨哩氧
救挹角
菠粥螳
官罄汕
韶群蔥
繭晾氳
禺豺僅
喃黔慍
敏勵錨
盟召杵
鋃紋嬸
鯖悃娌
掰墉蒸
劇襪鼾
柄慰駟
聲旯呻
疆憧趕
箋羹驀
題征留
冉錫髫
戕揩梳
愕躁稞
渠妥形
握飧躕
搡凡倩
洛褒靈
硇檳賅
神鄺濟
濺埤螫
趟黯直
擂瘺朋
鵲捷甌
狀庵粥
飼鄱哪
玷涕擐
鑠嶸疵
羆霆龠
庀靼讓
藕棼鷙
檑侏銘
荻詘邊
於雯彖
嗌鋯蘊
棹念辮
鼾徵芎
氬誶它
均塌暹
菩嘹銘
僻躉韙
咋實搪
壓嘶害
岣绱畀
納噘桅
鶇啞鼴

矛盾之問
TA貢獻1條經驗 獲得超0個贊
int?count?=?0; int?i?=?1; while(i<=1000){ ????if(i%5==0){ ????????System.out.print(i+"\t"); ????????count++; ????} ????if(count==3){ ???????System.out.println(); ???????count=0; ?????} i++; }
添加回答
舉報
0/150
提交
取消