#include <iostream>
using namespace std;
bool pals(int n) {
int remainder;
int reverse=0;
while(n>0){
remainder=n%10;
reverse=reverse*10+remainder;
n=n/10;
}
return reverse;
}
int main() {
int nums;
cout<<"Input Desired Number: ";
cin >>nums;
if(pals(nums)) {
cout <<nums<<" palindrome";
}
else {
cout <<nums<<" not a palindrome";
}
return 0;
}
Keeps returning " palindrome" when it isn't.
Is there something missing in my code or something wrong.
Any tips or pointers for future references would be good too. Thank you!
Any feedback is great! Thank You!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…