Чтобы прекратить ввод чисел в массив нужно ввести число "-1". class ArrayMiddle{ public static void main(String args[]){ java.util.Scanner in = new java.util.Scanner(System.in); long eArray[] = new long[1]; while((eArray[eArray.length-1] = in.nextLong())!=-1){ long nArray[] = new long[eArray.length+1]; for(int nCell = 0; nCell<eArray.length; nCell++)nArray[nCell]=eArray[nCell]; eArray = nArray; } eArray[eArray.length-1] = 0; for(int cCell = 0; cCell<eArray.length-1; cCell++)eArray[eArray.length-1]+=eArray[cCell]; System.out.print(eArray[eArray.length-1]/(double)(eArray.length-1)); } }
public static void main(String args[]){
java.util.Scanner in = new java.util.Scanner(System.in);
String string = in.nextLine(); char chars[] = new char[4];
chars[0] = in.nextLine().charAt(0); chars[2] = in.nextLine().charAt(0);
for(int sChar = 0; sChar<string.length(); sChar++)
if(string.charAt(sChar)==chars[0])chars[1]++;
else if(string.charAt(sChar)==chars[2])chars[3]++;
System.out.print("\n"+(chars[1]==chars[3]?chars[0]+""+chars[2]:chars[1]>chars[3]?chars[0]:chars[2]));
}
}
class ArrayMiddle{
public static void main(String args[]){
java.util.Scanner in = new java.util.Scanner(System.in); long eArray[] = new long[1];
while((eArray[eArray.length-1] = in.nextLong())!=-1){
long nArray[] = new long[eArray.length+1];
for(int nCell = 0; nCell<eArray.length; nCell++)nArray[nCell]=eArray[nCell];
eArray = nArray;
} eArray[eArray.length-1] = 0;
for(int cCell = 0; cCell<eArray.length-1; cCell++)eArray[eArray.length-1]+=eArray[cCell];
System.out.print(eArray[eArray.length-1]/(double)(eArray.length-1));
}
}