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

C# crash
Posted by Valentin Baltadzhiev 2 Oct 2012 07:32
I uploaded the following solution but it only says "crash":


using System;

namespace Week2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            Console.WriteLine(a + b);
        }
    }
}
Re: C# crash
Posted by PROger4everPublic 14 Oct 2012 01:55
It happens because of you use ReadLine. These digits are on the same line, so you should just split them by space. You can find an example there:
http://acm.timus.ru/help.aspx?topic=csharp

using System;

public class Sum
{
    private static void Main()
    {
        string[] tokens = Console.ReadLine().Split(' ');
        Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));
    }
}

Edited by author 14.10.2012 01:59