0 喜歡 0 不喜歡
1.2k 瀏覽

>>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.

 

[正常] Coding (C++) - 最新提問 分類:Introduction to Computer Programming II (C++) |
ID: 52073 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.2k 瀏覽

1個回答

0 喜歡 0 不喜歡
內容已隱藏
#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;
}
最新回答 用戶: (-286 分)
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:162.159.115.31
©2016-2026

相關問題

0 喜歡 0 不喜歡
0 回答
[正常] Coding (C++) - 最新提問 5月 17, 2018 分類:Introduction to Computer Programming II (C++) |
ID: 52071 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 878 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶