如何以单行显示输出

Ani*_*uri -5 c# arrays console

我的程序正在生成一个输出,但我期望一个与生成的输出不同的输出。如果我发送 6 个输入数字,它应该比较这些数字并生成一个答案。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Solution 
{
    static void Main(String[] args) 
    {
        string[] tokens_a0 = Console.ReadLine().Split(' ');
        
        int a0 = Convert.ToInt32(tokens_a0[0]);
        int a1 = Convert.ToInt32(tokens_a0[1]);
        int a2 = Convert.ToInt32(tokens_a0[2]);
        
        string[] tokens_b0 = Console.ReadLine().Split(' ');
        
        int b0 = Convert.ToInt32(tokens_b0[0]);
        int b1 = Convert.ToInt32(tokens_b0[1]);
        int b2 = Convert.ToInt32(tokens_b0[2]);
        
        if (a0 > b0 || a0 < b0)
        {
            Console.WriteLine(1);
        }
        if (a1 > b1 || a1 < b1)
        {
            Console.WriteLine(1);
        }
        if (a2 > b2 || a2 < b2)
        {
            Console.WriteLine(1);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码生成以下输出:

1

1

我需要输出像这样显示:

1 1

如何更改代码以这种方式生成输出?

Mat*_*ero 5

Console.WriteLine 完全按照名称所说的那样,它会写下您的消息,然后是一个新行。

如果你希望你的输出在同一行,你应该使用Console.Write

if (a0 > b0 || a0 < b0)
{
   Console.Write(1 + " ");
}
if (a1 > b1 || a1 < b1)
{
    Console.Write(1 + " ");
}
if (a2 > b2 || a2 < b2)
{
    Console.Write(1 + " ");
}
Run Code Online (Sandbox Code Playgroud)