using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PelindromeIdentifier
{
class Program
{
static void Main()
{
int nNumberOfTestCases = 0;
int.TryParse(Console.ReadLine(), out nNumberOfTestCases);
String[] strTestCases = new String[nNumberOfTestCases];
char[] arrChar;
int nCharCount = 0;
bool bAllow = false;
int nCharIndex = 0;
for (int nTestCase = 0; nTestCase < nNumberOfTestCases; nTestCase++)
{
strTestCases[nTestCase] = Console.ReadLine();
}
for (int nTestCase = 0; nTestCase < nNumberOfTestCases; nTestCase++)
{
bAllow = false;
arrChar = strTestCases[nTestCase].Distinct().ToArray();
for (nCharIndex = 0; nCharIndex < arrChar.Length; nCharIndex++)
{
nCharCount = strTestCases[nTestCase].Count(i => i.Equals(arrChar[nCharIndex]));
if (strTestCases[nTestCase].Length % 2 == 0)
{
if (nCharCount % 2 != 0)
{
Console.WriteLine("NO");
break;
}
}
else
{
if (nCharCount % 2 != 0)
{
if (bAllow == true)
{
Console.WriteLine("NO");
break;
}
bAllow = true;
}
}
}
if (nCharIndex == arrChar.Length)
{`
Console.WriteLine("YES");
}
}
}
}
}
我試過這個,但有一些隱藏的測試用例不工作。可以幫助我嗎?在這個程序中,程序會詢問用戶你有多少次要採取輸入字符串併爲每弦,它就會返回一個字符串是否是迴文與否WAP查找字符串是否是迴文或C#
可能重複從http://stackoverflow.com/questions/ 9790749/check-if-a-string-is-a-palindrome – Xavave
只是幫助什麼纔是可能的測試用例 –
隱藏的測試用例?真的嗎? – Sefe