Hello, Could You Please Help Me In Reading Input From input.txt
And Printing It To output.txt
In Java
Thanks
Thanks @akshitm16 It Worked Successfully, But This IO Method Is Not Working On Codeforces How Could I Achieve That
My Code:
package com.codeforces;
import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Eshag_Loves_Big_Arrays {
static int[] insertion_sort(int[] a){
for (int i = 0; i < a.length; i++){
int key = a[i];
int j = i - 1;
while (j>=0&&key<a[j]){
a[j+1]=a[j];
j--;
}
a[j+1]=key;
}
return a;
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(
new FileReader("input.txt"));
PrintWriter pw=new PrintWriter(new
BufferedWriter(new FileWriter("output.txt")));
Scanner scin = new Scanner(br);
int t = scin.nextInt();
while (t-->0){
int l = scin.nextInt();
int[] a = new int[l];
for (int i = 0 ; i < l; i++){
int g = scin.nextInt();
a[i]=g;
}
insertion_sort(a);
int i = 0;
while (i<l && a[i]==a[0]){
i++;
}
String x = String.valueOf(l-i);
pw.println(x);
}
pw.close();
}
}
Please Help
Thanks Again
You can’t do it on cf. There’s no file system there. You can only do it locally.