adding cp3

This commit is contained in:
Jidong Xiao
2023-11-05 01:16:09 -04:00
parent 1c30e6f4c8
commit 730c2d1d9d
2 changed files with 56 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <unordered_map>
bool isHappy(int n) {
}
int main() {
// Test cases
// 2, 4, 5, 6, 17, 18, 20 are not happy numbers.
// 1, 7, 10, 13, 19, 23, 28, 68 are not happy numbers.
int testCases[] = {2,4,5,6,17,18,20,68,1,7,10,13,19,23,28};
for (int n : testCases) {
if (isHappy(n)) {
std::cout << n << " is a happy number." << std::endl;
} else {
std::cout << n << " is not a happy number." << std::endl;
}
}
return 0;
}