當前位置:編程學習大全網 - 源碼下載 - Acg源博客

Acg源博客

包org . night runner . Baidu . zhidao;

導入Java . io . buffered reader;

導入Java . io . io exception;

導入Java . io . inputstreamreader;

公開課問題壹{

/**

*壹組序列由AGCT的四個字符組成,如:taacgagagagataaaaaaaaaaaaaaatgaggaaaaaaaaaaaaaaaagatggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaaggaag

*,請求壹個小程序。

*例如,輸入壹個字符串AAAG,並從頭開始。如果這個字符串是上面的序列,輸出:成功找到,記錄位置。如果沒有上述字符串,輸出:找不到,並退出。

*

* @param args

*/

公共靜態void main(String[] args) {

string data = " taacgagagagagattaaaaacaagaatgattgaaggacagaaaaggaaaaaaaagaagaacaatgatggataaggaggaggtggatgacaagattaaggaggaggagagataatagaagaaggattgaaggaagggaggaaggaaggaaaaaaaaaaaaaagaggaagaggagagat ";

System.out.println("請輸入壹個字符串,回車結束");

buffered reader reader = new buffered reader(new InputStreamReader(

system . in));

String line = null

嘗試{

line = reader . readline();

} catch (IOException e) {

e . printstacktrace();

}

int pos = data . index of(line);

if (pos == -1) {

System.out.println("找不到出口");

}否則{

System.out.println ("found,in first "+(pos+1)+"字符");

}

}

}

  • 上一篇:儋州哪裏可以股票開戶
  • 下一篇:籃球規則
  • copyright 2024編程學習大全網