This code is supposed to take 2 lines of input
- Number of integers k
- k integers seperated by a space
This code works fine for inputs of less than 230 integers but it's not working for more. I mean for inputs like 1000s and more. What is the issue?
I think the whole line is not read from console. But how to read the whole line?
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
class MyClass
{
static void Main(string[] args)
{
StreamReader reader = new StreamReader(Console.OpenStandardInput());
// Reads the number of integers to input
int k = int.Parse(reader.ReadLine());
List<int> pokemons = new List<int>(k);
string inputLine;
List<string> input = new List<string>(k);
int a;
inputLine = reader.ReadToEnd();
input.AddRange(inputLine.Split(new char[] { ' ' }));
Console.WriteLine(input.Count);
// Size of the input is never greater than 230.