如果輸入x = y + 5
檢查我的邏輯錯誤,請
,輸出必須是:
Token 1 is x is identifier
Token 2 is =
Token 3 is y is identifier
Token 4 is +
Token 5 is 5
,這是我沒有我不知道什麼是錯在我,如果條件代碼!
char[] ident = {'x','y','z','a','b','c','k'};
Scanner sc = new Scanner(System.in);
System.out.println("Please Enter Your String");
String x = sc.nextLine();
StringTokenizer t = new StringTokenizer(x);
for (int k = 0; k < ident.length; k++) {
for (int j = 1; j < x.length()+1; j++) {
char m = x.charAt(j);
if (m==ident[k]) {
System.out.println("Token " + j + " is " + t.nextToken()+" is identifier");
} else {
System.out.println("Token " + j + " is " + t.nextToken());
}
}
}
有什麼問題? – SMA 2014-12-07 17:04:47
運行代碼知道問題:D – 2014-12-07 17:13:31