Witam. Napisalem program, ktory porownuje takie liczby, ktorych long long int nie pomiesci. Wszystkie testy ze SPOJA oraz moje wlasne testy wychodza dobrze, a jednak SPOJ odrzuca.
Pomoze ktos?
#include<iostream>
#include<string>
using namespace std;
int check(string a, string relation, string b)
{
unsigned sizeA, sizeB;
if (relation == "==")
{
sizeA = a.length();
sizeB = b.length();
if (sizeA != sizeB) return 0;
else
{
for (unsigned i = 0; i < sizeA; ++i)
{
if (a[i]!=b[i]) return 0;
}
return 1;
}
}
else if (relation == "!=")
{
sizeA = a.length();
sizeB = b.length();
if (sizeA != sizeB) return 1;
else
{
for (unsigned i = 0; i < sizeA; ++i)
{
if (a[i] == b[i]) return 0;
}
return 1;
}
}
else if (relation == "<=")
{
sizeA = a.length();
sizeB = b.length();
if (sizeA > sizeB) return 0;
else if (sizeA < sizeB) return 1;
else if (sizeA == sizeB)
{
for (unsigned i = 0; i < sizeA; ++i)
{
if (a[i]>b[i]) return 0;
}
return 1;
}
}
else if (relation == ">=")
{
sizeA = a.length();
sizeB = b.length();
if (sizeA < sizeB) return 0;
else if (sizeA > sizeB) return 1;
else if (sizeA == sizeB)
{
for (unsigned i = 0; i < sizeA; ++i)
{
if (a[i]<b[i]) return 0;
}
return 1;
}
}
}
int main()
{
string a, b, relation;
while (cin >> a >> relation >> b)
{
if (check(a, relation, b)) cout << "1" << endl;
else cout << "0" << endl;
}
return 0;
}