0 thích 0 k thích
353 đã xem

>>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++) - đã hỏi trong Introduction to Computer Programming II (C++)
ID: 52073 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 353 đã xem

1 Câu trả lời

0 thích 0 k thích
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;
}
trả lời bởi (-286 điểm)
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.255.142
©2016-2024

Những câu hỏi liên quan

0 thích 0 k thích
0 trả lời
[Normal] Coding (C++) - đã hỏi ngày 17 tháng 5 năm 2018 trong Introduction to Computer Programming II (C++)
ID: 52071 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 256 đã xem
12,783 câu hỏi
183,443 trả lời
172,219 bình luận
4,824 thành viên