第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

java:輸入0,還是循環(huán)

java:輸入0,還是循環(huán)

函數(shù)式編程 2018-07-30 04:04:46
package javatest;import java.util.*;public class javatest{public static void num(int[] inp){for(int i=0;i<inp.length;i++){int temp=inp[i];int cur=0;int re=0;while(temp!=0){cur=temp%3;temp=temp/3;re=re+temp;temp=temp+cur;}if(cur==2)re=re+1;System.out.println(re);}} public static void main(String[] args){Scanner sc=new Scanner(System.in);int[] inp=new int[10];int i=0;while(sc.hasNextInt()){if(sc.nextInt()==0){break;}if(i<10){ inp[i]=sc.nextInt();i++;}elsebreak;}sc.close();num(inp);}}
查看完整描述

1 回答

?
守著一只汪

TA貢獻1872條經(jīng)驗 獲得超4個贊

int數(shù)組初始化好了大小,默認(rèn)所有元素都是0,肯定要把數(shù)組循環(huán)打印完的。要想打印輸入的東西,建議不要這樣寫

查看完整回答
反對 回復(fù) 2018-09-01
  • 1 回答
  • 0 關(guān)注
  • 543 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號