- Function sum_divisor that accepts one integer parameter num and
returns
the sum of the PROPER divisors of the parameter num.
- Function isabundant that accepts one integer parameter and returns 1
if
the number is abundant and 0 otherwise. Definition: an abundant number or
excessive number is a number for which the sum of PROPER divisors is
larger than the number itself. Use functin sum_divisors that you wrote, to
find the sum of proper divisors.
Examples:
12 is abundant, since the sum of the proper divisors is 1+2+3+4+6=16 > 12
20 is abundant, since the sum of the proper divisors is 1+2+4+5+10=22 > 20
6 is NOT abundant, since the sum of proper divisors is 1+2+3 = 6 and it is
NOT larger than 6
10 is not abundant, since the sum of proper divisors is 1 + 2 + 5 = 8 < 10
- int array_abundant that has two parameters: array of integers and size of the array. The
function
returns the number of
abundant numbers among array elements.
Write main to test your program. You can also write functions make_array and print_array.
Team Work
Mini-Sudoku
To solve a Mini-Sudoku puzzle, one must fill in a 4X4 grid with the
integers from 1 to 4 in such a way that each integer appears once in each
row, once in each column, and once in each 2X2 subgrid. (Normally Sudoku
is played on a 9X9 grid). For example, the following would be a solution.
1 2 3 4
3 4 1 2
2 1 4 3
4 3 2 1
Write a program which takes four rows of four integers as input. If the
grid represents a
legitimate solution, your program should print the words .Valid Solution.;
otherwise, it should print one or more of the following, depending on
which criteria fail:
- Invalid row
- Invalid column
- Invalid subgrid
Your program should display each reasons which is responsible for a
failure on a separate
line, but the same reason should not be given more than once. For example,
it might print
both 'Invalid row' and 'Invalid subgrid' if both of these reasons apply,
but it should print
'Invalid row' only once, regardless of how many rows actually fail.
You may assume the input consists only of integers from 1 to 4, and that
there are exactly four rows, each with four integers.
Use two dimensional array to solve this problem
Here are some sample inputs, along with the corresponding output.
Input
1 2 3 4
3 4 1 2
2 1 4 3
4 3 2 1
Output: VALID
Input
1 2 3 4
4 3 2 1
1 2 3 4
4 3 2 1
Output: Invalid column
Input
2 2 2 2
1 1 1 1
3 3 3 3
4 4 4 4
Output: Invalid row, Invalid subgrid
Input
3 3 3 3
3 3 3 3
3 3 3 3
3 3 3 3
Output: Invalid row, Invalid column,
Invalid subgrid