Pagini recente » Cod sursa (job #3277231) | Cod sursa (job #2093178) | Cod sursa (job #2777434) | Cod sursa (job #2028345) | Cod sursa (job #1547231)
package com.company;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException
{
// write your code here
Scanner s = new Scanner("adunare.in");
int a = (s.nextInt());
int b = (s.nextInt());
// System.out.println(s.read());
Writer w = new Writer("adunare.out");
int n = a + b;
w.write(Integer.toString(n));
}
}
class Writer
{
FileOutputStream file;
Writer(String fname) throws IOException
{
file = new FileOutputStream(fname);
}
void write(String str) throws IOException
{
file.write(str.getBytes());
}
}
class Scanner
{
FileInputStream file;
boolean hasNext = true;
Scanner(String fname) throws IOException
{
file = new FileInputStream(fname);
}
int nextInt() throws IOException
{
String out = "";
int b = '5';
while(b != -1 && (b >= '0' && b <= '9'))
{
b = file.read();
// System.out.printf("%d\n",b);
if(b == -1)
hasNext = false;
else if(b >= '0' && b <= '9')
out += (char)b;
}
file.read();
// System.out.println("a"+out+"b");
return Integer.parseInt(out);
}
String read() throws IOException
{
int b = 0;
String out = new String();
while (b != -1)
{
b = file.read();
if (b == -1)
hasNext = false;
else
out += b+"\n";
}
return out;
}
boolean hasNext()
{
return hasNext;
}
}