我一直在试图解决这个黑客练习题(Compare the Triplets),我不知道我错在哪里。我的输出是正确的,但它并没有通过hackerrank的所有测试用例。有什么建议?比较三胞胎C#hackerrank改进我的解决方案
问题:
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]);
// Write Your Code Here
int aliceScore = 0;
int bobScore = 0;
if(a0 > b0 || a1 > b1 || a2 > b2)
{
aliceScore++;
}
if(b0 > a0 || b1 > a1 || b2 > a2)
{
bobScore++;
}
if(a0 == b0 || a1 == b1 || a2 == b2)
{
aliceScore += 0;
bobScore += 0;
}
Console.WriteLine(aliceScore +" " + bobScore);
}
}
我认为你的3rd if语句没有任何用处。 – GER
在你的版本中,任何一个玩家只能有0或1分。这显然是错误的 – UnholySheep
让您的代码在问题 – Alyafey