How to read multiple lines of input for C ?

Back to Programming Languages forum

asadmahmood1995     2018-02-10 14:04:34

I'm using C# to complete the problems, and so far I have done a few of them and have noticed that the test data puts a lot of zeros in my output, though when I run the compiler on VS and I manually enter the test input everything's okay.

I don't want to give out any answers for any of the problems, so if you wish to check my code for them please look at my profile!

Quandray     2018-02-10 18:17:10
User avatar

I don't use C#, so keep that in mind when you read on.
I looked at your code for Sum A+B and the way you read the input seems "odd".
I looked at other submissions using C# and I couldn't find anything that looked similar to your way of doing it.
Have a look at some of the other C# submissions to see if that helps. Some of them "hard code" the values, so just ignore those.
Otherwise, does the C# bit of http://www.codeabbey.com/index/wiki/running help?

J_Language     2018-03-04 16:39:00
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Console.ReadLine().Split().Sum(Int32.Parse));
    }
}
Please login and solve 5 problems to be able to post at forum