Cześć, robię zadanie ze SPOJ https://pl.spoj.com/problems/KC015/
Na początku chciałem zrobić kod pod długoś tablicy, a potem zmienić ją, żeby patrzyła jeszcze czy wnętrze się różni.
Nie wiem co zmienić, żeby nie było błędu **Nie można zastosować operatora „>=” do argumentów operacji typu „string” lub „string”. **
Oto mój kod:
static void Main(string[] args)
{
string[] tab = Console.ReadLine().Split(' ');
String1 string1 = new String1(tab[0], tab[1], tab[2]);
if (tab[1] == "==")
{
if (tab[0].Length == tab[2].Length)
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("0");
}
}
else if (tab[1] == "!=")
{
if (tab[0].Length != tab[2].Length)
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("0");
}
}
else if (tab[1] == ">=")
{
if (tab[0] >= tab[2])
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("0");
}
}
else if (tab[1] == "<=")
{
if (tab[0] <= tab[2])
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("0");
}
}
Console.Read();
}
public class String1
{
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
public String1(string a, string b, string c)
{
A = a;
B = b;
C = c;
}
}
Czy da się skopiować tab[1] do tablicy int?