pages:
Arvant SAYS

الان تو سی پلاس پلاس این اشتباهه؟

include

using namespace std;

int main() { int a=0,b=0; cin>>a>>b; cout<<a+b; return 0; }

AMiR SAYS

Arvant said:

الان تو سی پلاس پلاس این اشتباهه؟

include

using namespace std;

int main() { int a=0,b=0; cin>>a>>b; cout<<a+b; return 0; }

First of all, please post you source code in discussion in code format. You can hit a tab or 4 spaces before each line.

Please read the markdown help. You can also read the short help on the top of reply text box.

Second, you have to read the input until EOF. Try this:

int a, b;
while (cin >> a >> b) {
    cout << a+b << endl;
}
M.Khademloo SAYS

من موندم که چرا 2 تا فارسی باید با هم انگلیسی حرف بزنن. راحت باشین و موفق

Dariush SAYS

سلام دوستان من تازه کار هستم و یک مشکلی دارم اگه بخوام با C++ توی ورودی بین ورودی هام فاصله باشه باید چیکار کنم؟؟؟؟ مثل 1 5 برای مسئله مجموع دو عدد میخوام

AMiR SAYS

Dariush said:

سلام دوستان من تازه کار هستم و یک مشکلی دارم اگه بخوام با C++ توی ورودی بین ورودی هام فاصله باشه باید چیکار کنم؟؟؟؟ مثل 1 5 برای مسئله مجموع دو عدد میخوام

int a, b;
while (cin >> a >> b) {
    cout << a+b << endl;
}
azureowl SAYS

Hi everyone. I've been having some problems submitting a Java program. Here's my code:

import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception{
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()){
            System.out.println(scan.nextInt()+scan.nextInt());
        }
    }
}

It works with my computer, even if I add extra lines and spaces after the numbers. But the Judge tells me he gets a RuntimeError.

Can someone help me figure out what's wrong?

AMiR SAYS

azureowl said:

Hi everyone. I've been having some problems submitting a Java program. Here's my code:

import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception{
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()){
            System.out.println(scan.nextInt()+scan.nextInt());
        }
    }
}

It works with my computer, even if I add extra lines and spaces after the numbers. But the Judge tells me he gets a RuntimeError.

Can someone help me figure out what's wrong?

Your code is working fine. The problem is you have used a package in your main file.

You should not use any package name for your source code. Everything must be in the default package.

Masoud Rahmani SAYS

Hi . sorry to intrupt But The way you explaind in The question . it made me think that the Input data is from Some file .

that would be mush harder ... i was trying to solve that problem and i did .

main reason of my confusion was beacuse you said " EOF " = End of File .

AMiR SAYS

Masoud Rahmani said:

Hi . sorry to intrupt But The way you explaind in The question . it made me think that the Input data is from Some file .

that would be mush harder ... i was trying to solve that problem and i did .

main reason of my confusion was beacuse you said " EOF " = End of File .

Standard input and output are files too.

In online judge systems, IO comes and goes to files. You can use this commands in your machine to test whether your solution works fine or not.

./my_solution_binay < input.txt > my_output.txt

It makes your standard input redirects to input.txt and print your standard output to my_output.txt :)

bardiia SAYS

سلام دوستان ایرانی چگونه ورودی خروجی ها رو باید ست کرددر c++ cin>> cout>> به من جواب بدین

pc2 بعد کسی از دوستان با کار کرده به من اطلاع بده نیاز دارم به کمکش ممنون