Question: Write a C++ code for this: Let us suppose that integers 3 and 5 are lucky numbers. For example, 35, 533, 5 are lucky and
Write a C++ code for this:
Let us suppose that integers 3 and 5 are lucky numbers. For example, 35, 533, 5 are lucky and 2, 13, 563 are not.
We have cards and each card has a number that is a positive integer. Its length equals n (n is always even). A card is lucky if the cards number is a lucky number and the sum of digits in the first half (the sum of the first n/2 digits) equals the sum of digits in the second half (the sum of the last n/2 digits). Check if the given card is lucky.
Input: The first line contains an even integer n (2n50) the length of the card number that needs to be checked. The second line contains an integer whose length equals exactly n the card number. The number may contain leading zeros.
Output: On the first line print "YES" if the given card number is lucky. Otherwise, print "NO".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
