亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

可是這組代碼里面的equals明顯比較的是兩個變量的值?。壳蠼?/h1>

package Math;

import java.util.Scanner;

import java.util.Arrays;

public class 裴波那契數列 {

public static void main(String [] args){

System.out.println("*****裴波那鍥數列*****");

Scanner input=new Scanner(System.in);

裴波那契數列 對象 =new 裴波那契數列();

對象.survey();

for(int i=1;;){

System.out.println("您需要再次測試嗎?");

System.out.println("回答“Y”or“N”");

? ? ? ? String x=input.next();

? ? ? ? String s1="y",s2="Y",s3="n",s4="N";

? ? ? ? if(x.equals(s1)){

? ? ? ? 對象.survey();

? ? ? ? i++;

? ? ? ? }

else if(x.contentEquals(s2)){

對象.survey();

i++;

}

else if(x.contentEquals(s3)){

System.out.println("測試"+i+"次.");

break;

}

else if(x.equals(s4)){

System.out.println("測試"+i+"次.");

break;

}

else{

System.out.print("您的輸入有誤,請問");

}

? ?}

}

public ?void survey(){

Scanner input=new Scanner(System.in);

System.out.println("***請輸入長度***");

int c=input.nextInt();

for(int leng=c;c<2;){

System.out.println("您的輸入有誤,請重新輸入");

c=input.nextInt();

}

for(int leng=c;c>45;){

System.out.println("您的輸入有誤,請重新輸入");

c=input.nextInt();

}

int scores[]=new int[c];

scores[0]=1;

scores[1]=1;

for(int i=2;i<scores.length;i++){

scores[i]=scores[i-2]+scores[i-1];

}

System.out.println("結果:");

System.out.println(Arrays.toString(scores));

}

}


正在回答

1 回答

。。。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

可是這組代碼里面的equals明顯比較的是兩個變量的值???求解

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號