0 like 0 dislike
1k views

>>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++)
ID: 52073 - Available when: Unlimited - Due to: Unlimited
| 1k 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
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.254.112
©2016-2025

Related questions

0 like 0 dislike
0 answers
[Normal] Coding (C++) - asked May 17, 2018 in Introduction to Computer Programming II (C++)
ID: 52071 - Available when: Unlimited - Due to: Unlimited
| 709 views
12,783 questions
183,442 answers
172,219 comments
4,824 users