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

前端 未结 7 1767
小蘑菇
小蘑菇 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条回答
  • 2020-12-01 13:52

    This will help you to remove extra blank spaces present at the end or beginning of the input string.

    string daat1String = Console.ReadLine();
    daat1String = daat1String.TrimEnd().TrimStart();
    string[] data1 = daat1String.Split(null);
    int[] data1Int = Array.ConvertAll(data1, int.Parse);
    
    0 讨论(0)
提交回复
热议问题