ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

Where is the problem???
Posted by InitInstance 2 May 2008 04:15
#include <iostream>
int main()
{
    int a,b;
    FILE* f1;
    FILE* f2;
    f1 = fopen("input.dat", "r");
    f2 = fopen("output.dat", "w");
    fscanf(f1, "%d %d", &a, &b);
    fprintf(f2, "%d", a + b);
    return 0;
}

It gives when submitted Crash (access viaolation)...
I have no idea what the problem may be...
Re: Where is the problem???
Posted by Alias aka Alexander Prudaev 2 May 2008 10:30
you don't need to open any files
use scanf and printf. see FAQ for clarification.
Re: Where is the problem???
Posted by InitInstance 2 May 2008 23:17
Oh, I have obviosly misunderstood the problem.
Thanks for the help!
Re: Where is the problem???
Posted by Hernan 9 May 2008 09:20
import java.util.*;
class Sumar
{
    private int a,b;
    public Sumar(int a,int b)
    {

        this.a=a;
        this.b=b;
    }
    public int sumar()
    {
        return a + b;
    }
     public static void main (String[] args)
    {
        int a,b;
        Scanner in =new Scanner(System.in);
         a=in.nextInt();
         b=in.nextInt();
         Sumar res=new Sumar(a,b);
        System.out.print(res.sumar());

    }
}
InitInstance wrote 2 May 2008 23:17
Oh, I have obviosly misunderstood the problem.
Thanks for the help!