+ 1
It's a Sign WORKS WRONG?
my code sample using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(" "); foreach (string s in input) { if(IsPolinom(s)) { Console.WriteLine("Open"); return; } } Console.WriteLine("Trash"); } static bool IsPolinom(string s) { char[] arr = s.ToCharArray(); Array.Reverse(arr); return new string(arr)==s; } } } Why it can't pass all tests?
4 Answers
0
No. Logic of test is if one of word in array is polynomial then Open.That's why no need to end foreach search if true. If we can't find Polynom then Trash. But my issue not working on test 3 and 5.
0
static void Main(string[] args)
{
string[] x = new string[4];
int i;
for (i = 0; i < 4; i++)
{
x[i] = Console.ReadLine().Trim();
}
foreach (string s in x)
{
if (IsPolinom(s))
{
Console.WriteLine("Open");
return;
}
}
Console.WriteLine("Trash");
}
static bool IsPolinom(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr) == s;
}
0
чуть-чуть доделал)
- 2
Guess you might wanted this?
foreach (string s in inputs)
{
if(IsPolinom(s))
{
Console.WriteLine("Open");
return;
} else {
Console.WriteLine("Trash");
}
}