0 like 0 dislike

>>Full Screen<<

NOTE: There is a blank line after each separate case, excluding the last one. 

Sample Input:

3
7
4
13

Sample Output:

Case #1: 7 is a Happy number.
Case #2: 4 is an Unhappy number.
Case #3: 13 is a Happy number.

 

[Normal] Coding (C++) - asked in Introduction to Computer Programming II (C++)
Available when: Unlimited - Due to: Unlimited
| 54 views

1 Answer

0 like 0 dislike
Hidden content!
#include <iostream>
#include <cmath>

using namespace std;
//Elvis Suazo
///Happy number :)
int seen_numbers[100]={0};
int flag=0;
int j=0;

///Determines if it's a happy happy number
int IsHappy(int x){


* ** ** * * * * ** i,a[20]={0},counter=0;




**** * * ** * * * * * ** for a sequence loop
**** * ****** ** * * ** * ** * ** **** **
* * * ** ** * * * * *** ** ** *** * * *** ** ******* **** *** **
* * * * ** * * * * * **** * * * ***** ** *** * * * * * *** * ** * **** *
* * * * * ** ***** *** * * *** ** * ** * * ** * ** * * **
* **** * * * *** * * ** *** * ******* * * * ** ** ** ** ** ** * * * ******* * *
* * *** * ** ** * *** ***** * ** * ** * ** * ** ** * * * ** * ** *** * ** ** * * * * **** * * ***
* ** ****** ** * * ** *** * ** ** ** *** ** * ******** * *
* ** * * * * *** * * * * * **** *** *** * * *** *** * ** 0;
**** * ** * **** ** * * *** * *** ** * * *
* * *** ***** * * ** *** *

***** ** ** ****** *** * * the end result is 1, the the number in question is a happy number
****** ****** * * * * * * ***
****** * ** * * ** ** *** ** * * * ** * **** * **** *
** * * *** * ** * ***** **** * *** *** * **
* ** * *** ** * * ** ** ****** *** *** * * ** * ** ** * ** * **
***** ** * **** *** ** * * ** * *** ******* ** *** ********* ******* * * * *
* * *** * *** ** * * ***** ****
*** * * *** ** * * * * * ** ** ** * ** *** ** 1;
** ** * * * * **

* * ****** **** ***** * ** the seen numbers list
*** * * ******* * ** *** ** *** ***
* ** ** * ** ** * *

** * * ** ******** * *** << "x= * * ******** * * *** ** ** * "numbers: ";
*** * ******* * * *** ** gets the individual digits from the number
** * ****** ** ***** * *** * * * *** **** * * ** *

**** * ** ***** *** * ** * ** ***** * ** * **
*** ** ** * * * * ** * * ** ** * * ** ** **** *** ****** ** ** ** * *
**** ** * *** *** * ** **** *** * ** * * * * *** ** **** * *** << a[counter] << " ";
** **** * * ********** *** * ******** ***** **** * *** ** * * * **** *
*********** *** ** ** * *** * *** * *** *** ** * * ** * ** * * * * * *
* ** *** * ** * * ** * * ** **** * ** ** ****


* ***** ** ** ****
*** **** * ** * ****** ** **** << * * * * * * ***** ** * ** ** * ****** *
**** ** * *** ** *

*** *********** * * * ** * gets the sum of the squares
* * * *** ** *** **** ** * **** *
* ** ** ***** * ** * * * * * * * * *** * * *
* * *** *** * *

* * **** * ** **** ** * * **

* *** * ** * **** * *
**** **** * ** * ***** * IsHappy(x);
}


int main(){
* ** * * ** ** * **** n,i;
** * ** * ** *** * * >> n;
**** * * * ********* *** ****** * << * ** * * ** *
****** * *** * ** * ** * {cout << * * * * ******* * * *
*** *** * * * * numbers[n];
* * **** * *** * ** ** of numbers
*** * * ** * * (i=0;i<n;i++){cin >> numbers[i];}
* ** * ** ** *** *** * * (i=0;i<n;i++){cout << numbers[n] << " ";}

* * * *** ** ****** *** **** of results
* ** **** * * * * *** * (i=0;i<n;i++){

* * ** * ** ** *** ** ** ** * ** * * ***** *** ** ** * ** ** *

** * * * * * ** * * *** ******** *** * *** * * * * * * * << "Case * * *** * *** **** * *** * * * " << * *** *** * * * is a Happy number.";}
** ** * ** * ** * * * * * ** ***** * *** * *** {cout << "Case * **** *** * *** ** * ** *** " << ** *** ** * * * *** is an Unhappy number.";}
* * ** *** **** * ** *** ***** * ***** * * ******** * ******** ***
* ** * * ** **** **


**** * * * ** *** 0;
}
answered by (-286 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.62.40
©2016-2020

Related questions

0 like 0 dislike
0 answers
9,614 questions
94,666 answers
76,330 comments
2,916 users