【发布时间】:2021-01-06 08:03:46
【问题描述】:
#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;
}
如果不是,则继续返回“回文”。
我的代码中是否缺少某些内容或有什么问题。
未来参考的任何提示或指示也会很好。谢谢!
任何反馈都很棒!谢谢!
【问题讨论】:
标签: c++ function numbers palindrome