Pagini recente » Cod sursa (job #2154399) | Cod sursa (job #1843675) | Cod sursa (job #2266166) | Cod sursa (job #381827) | Cod sursa (job #2878188)
Utilizator |
Andrei andreizx |
Data |
26 martie 2022 02:32:28 |
Problema |
A+B |
Scor |
0 |
Compilator |
java |
Status |
done |
Runda |
teme_upb |
Marime |
1.05 kb |
package elementeDeBaza;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class AsumB {
public static void main(String[] args) {
int a = 10, b = 220;
try {
File file = new File("adunare.in");
File file1 = new File("adunare.out");
file.createNewFile();
file1.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
try {
File file = new File("adunare.in");
Scanner scanner = new Scanner(file);
a = scanner.nextInt();
b = scanner.nextInt();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
FileWriter fileWriter = new FileWriter("adunare.out");
fileWriter.write(a + b + "");
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}