Ich versuche ein Programm zu schreiben, das alle Palindrom in Reichweite [a, b] drucken würde. Ich habe dies bisher geschrieben, aber nichts wird gedruckt, nachdem ich die Werte für a, b eingegeben habe. Was fehlt?Drucken aller Palindromzahlen in einem bestimmten Bereich
#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;
}
es kein Skript ist es ein Programm ist –
Sie Neuinitialisierung 't' nicht vor jedem Aufruf' reverse() ' –
Wenn Sie Schleife' while (a <= b) ', wenn tun Sie erwarte 'b molbdnilo