Created
April 8, 2016 02:45
-
-
Save DiegoNaterasPonce/e3d1aa2b4a2d7c887e3fde288b7c7b27 to your computer and use it in GitHub Desktop.
#WSQ11 #YoSoy196
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int reverse(long num){ | |
long numRev=0; | |
long sum; | |
int cont=-1; | |
do{ | |
sum=num; | |
numRev=0; | |
while (num!=0){ | |
numRev = numRev*10+(num%10); | |
num = num/10; | |
} | |
cont++; | |
num =numRev+sum; | |
} | |
while(sum!=numRev && cont!=30); | |
return cont; | |
} | |
int main (){ | |
int LowerBound, UpperBound, palindrome, Palindrome=0, NonLycherels=0, Lycherels=0; | |
cout << "Tell me the Lower Bound of the sequence\n"; | |
cin >> LowerBound; | |
cout << "Tell me the Upper Bound of the sequence\n"; | |
cin >> UpperBound; | |
for(int c=LowerBound; c<UpperBound+1; c++){ | |
reverse(c); | |
palindrome=reverse(c); | |
if(palindrome==0){ | |
Palindrome++; | |
} | |
else if (palindrome<30){ | |
NonLycherels++; | |
} | |
else if (palindrome==30){ | |
Lycherels++; | |
} | |
} | |
cout << "The Palindrome number is: " <<Palindrome<<endl; | |
cout << "The NonLycherels number is: " <<NonLycherels<<endl; | |
cout << "The Lycherels number is: " <<Lycherels<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment