If you are doing HDU 1073,HDU 1075 you will find this problem.
Hey. This is for the novice to see,, after all, this problem let me too tangled, WA did not know how many times, the heart is stuffed.
Later I found that my input method is not right, we can compare the input data, of course, the first two questions I have posted in the blog, you can search the search bar.
Bad input:
Error 1)
Import Java.util.Scanner;
public class p1075 {public
static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
Enter a part of the dictionary
string s = new string ();
s = sc.nextline ();// There may be tabs
s = sc.nextline ();//overwrite Start row data while
(!s.equals ("End")) {
S + = \ n; Line breaks can be displayed in a single line to avoid data not showing
S + + sc.nextline ();
}
System.out.println ("++s++" + s);
}
No output results----
Error 2)
Import Java.util.Scanner;
public class p1075 {public
static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
Enter a part of the dictionary
string s = new string ();
s = sc.nextline ();// There may be tabs
s = sc.nextline ();//overwrite Start row data while
(!s.equals ("End")) {
S + = \ n; Line breaks can be displayed in a single line to avoid data not showing
S + + sc.nextline ();
System.out.println ("1" + s);
}
System.out.println ("++s++" + s);
}
The output is the correct result
Error 3)
Import Java.util.Scanner;
public class p1075 {public
static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
Enter a part of the dictionary
string s = new string ();
s = sc.nextline ();// There may be tabs
s = sc.nextline ();//overwrite Start row data while
(!s.equals ("End")) {
S + = \ n; Line breaks can be displayed in a single line to avoid data not showing
S + + sc.nextline ();
System.out.println ("1" + s);
}
System.out.println ("++s++" + s);
Re
-Enter string s2 = new string ();
s = Sc.nextline ();
s = Sc.nextline ();
while (The!s2.equals ("End")) {
S2 = = \ n;//can be displayed single-line with a newline character to avoid the data not showing
s2 + = Sc.nextline ();
}
System.out.println ("++s2++" + s2);
}
Second entry Error
The correct input:
Import Java.util.Scanner;
public class p1075a {public
static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
string S1 = "";//Incoming character
string a = "";
S1 = Sc.nextline ();
S1 = Sc.nextline ();
int count = 0;
while (!s1.equals ("End")) {
if (count!= 0) {
A + = "\ n";
}
count++;
A + + S1;
S1 = Sc.nextline ();
}
System.out.println ("A:" + a);
}
}