我正試圖編寫一個程序來打印範圍[a,b]中的所有迴文。我已經寫了這個到目前爲止,但是我輸入a,b的值後沒有打印。什麼不見了?打印給定範圍內的所有迴文數字
#include "stdafx.h"
#include <iostream>
using namespace std;
int t = 0, rmd, z, a, b;
int reverse() {
while (z != 0) {
rmd = z% 10;
t = t * 10 + rmd;
z/= 10;
}
return t;
}
int palin() {
if (a == reverse()) {
return 1;
}
else
return 0;
}
int main() {
cout << "a: "; cin >> a;
cout << "b: "; cin >> b;
while (a <= b) {
z = a;
if (palin())
cout << a << endl;
a++;
}
system("pause");
return 0;
}
它不是一個腳本這是 –
你不重新初始化't'每次調用之前'扭轉程序()' –
如果循環',而(A <= B)',你什麼時候期望'b molbdnilo