Pagini recente » Cod sursa (job #2591916) | Cod sursa (job #3213493) | Cod sursa (job #669036) | Cod sursa (job #2714188) | Cod sursa (job #1725572)
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String []args){
int suma = 0;
try {
File f=new File("adunare.in");
Scanner s= new Scanner(f);
while (s.hasNextInt()){
suma+=s.nextInt();
}
s.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
File g=new File("adunare.out");
FileWriter wr=new FileWriter(g);
System.out.println(Integer.toString(suma));
wr.write(Integer.toString(suma));
wr.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}