Pagini recente » Istoria paginii runda/noaptea_burlacilor3/clasament | Cod sursa (job #440278) | Cod sursa (job #1046251) | Cod sursa (job #2916550) | Cod sursa (job #1651359)
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
class Sum{
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new FileReader("adunare.in"));
int sum=0;
String line;
while((line=br.readLine())!=null){
int x=Integer.parseInt(line);
sum+=x;
}
br.close();
FileWriter fw = new FileWriter("adunare.out");
fw.write(""+sum);
fw.close();
}
catch (FileNotFoundException e) {
System.out.println("File not Found!");
}
catch (IOException ex) {
Logger.getLogger(Sum.class.getName()).log(Level.SEVERE, null, ex);
}
}
}