import java.io.*; import java.util.Date; import java.util.Arrays; public class liitmine2 { public static String[] scores=new String[11]; static void freadtoarray() throws IOException { BufferedReader failist=new BufferedReader(new FileReader("scores.txt")); String rida=failist.readLine(); for(int i=0;rida!=null;i++) { scores[i]=rida; rida=failist.readLine(); } failist.close(); } static void fprintf(int time, String name)throws IOException { PrintWriter faili=new PrintWriter(new FileWriter("scores.txt", false)); if(time<=9999) scores[10]=time+" "+name; if(time<=999) scores[10]="0"+time+" "+name; if(time<=99) scores[10]="00"+time+" "+name; if(time<=9) scores[10]="000"+time+" "+name; Arrays.sort(scores); for(int i=0;i<=9;i++) faili.println(scores[i]); faili.close(); } public static void main(String argumendid[])throws IOException { Date date1=new Date(); //int oigevastus; int oigeid=0; long algus=date1.getTime(); String nimi; BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); for(int i=0;i<=9;i++) { int a=(int)(Math.random()*1); int b=(int)(Math.random()*1); System.out.println(a+"+"+b); int vastus=Integer.parseInt(input.readLine()); if(vastus==a+b) oigeid++; } date1=new Date(); int aeg=(int)((date1.getTime()-algus)/1000); int pcent=(int)((oigeid*100)/10); System.out.println("6igeid vastuseid: "+pcent+"%"); System.out.println("Aega l2ks "+aeg+" sekundit"); if(pcent==100) { for(int i=0;i<=10;i++) scores[i]="9999 pr22ks"; nimi=input.readLine(); freadtoarray(); //System.out.println(scores[0]); fprintf(aeg, nimi); } } }