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

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

?求大神幫忙解析java代碼?

?求大神幫忙解析java代碼?

蒲公英wsg 2016-11-08 00:15:13
import?java.util.*; public?class?Huiwen2?{ public?static?void?main(String[]?args){ Stack<String>?s=new?Stack<String>();? @SuppressWarnings("resource") Scanner?input=new?Scanner(System.in); System.out.println("輸入一串字符,以#結束:"); String?s1=(String)?input.nextLine(); while(s1.charAt(s1.length()-1)!='#'){ System.out.println("請以#為結尾,重新輸入:"); s1=input.nextLine();} ?????for(int?i=0;i<s1.length();i++){ s.push(s1); ?????} s.pop(); Queue<String>?q=new?LinkedList<String>?(); for(int?i=0;i<s1.length();i++){ q.offer(s1); ?????} /**/ String?str0=new?String(); String?str1=new?String(); String?str2=new?String(); int?i=0,flag=0; while?(i<str0.length())? { q.offer(str0.substring(i,i+1));??? s.push(str0.substring(i,i+1));??? i++; }? System.out.println(q.toString()); System.out.println(s.toString()); while?(!s.empty()) { str1=q.poll(); str2=s.pop(); if?(!str1.equals(str2)) ????????????????????????{ ?????flag=1; ?????????????????????????????break; } } System.out.println(q.toString()); System.out.println(s.toString()); /**/ if(q.poll()==s.pop()){ System.out.println("回文"); } else{System.out.println("不是回文");} } } 有個妹子問我,以我的能力改不了這個代碼。 這個代碼好像還有異常產生。有沒有大神幫我改一下,再給我簡單講一下。 在下感激不盡。。。求大神指教
查看完整描述

4 回答

  • 4 回答
  • 0 關注
  • 1526 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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