Read numbers from the console given in a single line, separated by a space

前端 未结 7 1807
小蘑菇
小蘑菇 2020-12-01 12:58

I have a task to read n given numbers in a single line, separated by a space ( ) from the console.

I know how to do it whe

7条回答
  •  猫巷女王i
    2020-12-01 13:50

    You simply need to split the data entered.

    string numbersLine = console.ReadLine();
    
    string[] numbers = numbersLine.Split(new char[] { ' '});
    
    // Convert to int or whatever and use
    

提交回复
热议问题