Witam, napisałem sobie dwa podprogramy potrzebne w pewnym zadanku, a wy jak oceniacie kod? Podajcie jak wy byście to zakodowali (sprawdzenie palindromu i odwrócenie cyfr). Jakie algorytmy?
int odwroc(int x)
{
temp = to_string(x);
for(size_t i = 0; i < temp.length()/2; i++)
{
swap(temp[i], temp[temp.length()-1-i]);
}
return atoi(temp.c_str());
}
bool palindrom(int x)
{
temp = to_string(x);
for(size_t i = 0; i < temp.length()/2; i++)
{
if(temp[i] != temp[temp.length()-1-i])
return false;
}
return true;
}