|  | 
|  | 
| вернуться в форум | Please, help me (JAVA), why WA 1? My prog gives right answer!! import java.io.*;
 public class TaskTimus
 {
 public static void main(String[] args) throws IOException
 {
 new TaskTimus().vvod();
 }
 
 String s = ""; String s1 = ""; String a[] = new String[120]; char c;
 int sch = -1, mistake = 0; String slovo = "";  int osh = 0; boolean bo = true;
 
 void vvod() throws IOException // INPUT THE DICTIONARY
 {
 BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
 while (true)
 {
 slovo = r.readLine();
 if ("#".equals(slovo)) break;
 sch++;
 a[sch] = slovo;
 }
 prov();
 }
 
 void prov() throws IOException  //INPUT THE TEXT (FILE OR TIMUS CONSOLE)
 {
 
 boolean oj = System.getProperty("ONLINE_JUDGE") != null;
 Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("C:\\test.txt");
 StreamTokenizer st = new StreamTokenizer(new BufferedReader(reader));
 st.eolIsSignificant(true);
 st.wordChars(32,47);
 st.wordChars(58,64);
 
 while (st.nextToken() != StreamTokenizer.TT_EOF)
 {
 if (st.ttype == StreamTokenizer.TT_WORD)
 s+=st.sval;
 
 if (st.ttype == StreamTokenizer.TT_EOL)
 {
 analysis();
 s = "";
 }
 }
 if (s!="") analysis();
 System.out.print(osh); // END OF INPUT, WRITE NUMBER OF MISTAKES
 }
 
 void analysis() throws IOException // CHECK
 {
 StringReader sr = new StringReader(s);
 for (int i = 0; i < s.length(); i++)
 {
 c = (char) sr.read();
 if (c <= 'z' && c >= 'a' || c <= 'Z' && c >= 'A') s1 += c;
 else mist();
 
 }
 if (s1!="") mist();
 System.out.println();
 sr.close();
 }
 
 void mist() throws IOException  // SEARCHING OF MISTAKE
 {
 for (int j = 0; j<=sch; j++)
 {
 if (a[j].length()==s1.length())
 {
 for (int k = 0; k<s1.length(); k++)
 {
 if (a[j].charAt(k)!=s1.charAt(k)) mistake++;
 if (mistake>1) { mistake = 0; break; }
 }
 if (mistake == 1)
 {
 System.out.print(a[j]);
 if (!(c <= 'z' && c >= 'a' || c <= 'Z' && c >= 'A')) System.out.print(c);
 osh++; bo = false; mistake = 0; break;
 }
 }
 }
 if (bo) System.out.print(s1); if ( (!(c <= 'z' && c >= 'a' || c <= 'Z' && c >= 'A')) && bo) System.out.print(c);
 s1=""; bo = true; mistake = 0;
 }
 }
 
 Edited by author 08.07.2014 00:57
Re: Please, help me (JAVA), why WA 1? My prog gives right answer!! Послано Wasdek  7 июл 2014 11:38Did you check a problem with "enter" symbols that i said you? Because, I don't know how  Stream Tokenizer works, and don't see fix for this in output mechanism. Maybe problem in this. | 
 | 
|