$30.00

Category: COMP 281

Description

5/5 - (5 votes)

Problem 1014

Title: Area and circumference of circles

Description:

In this exercise you have to compute the area and circumference of a series of circles and output their sum.

Specifically, the program will take two radii of two circles as input (r1 <= r2, both integers) and will output the sum of

the areas and the circumferences of all circles starting with r1 and increasing at each step the radius by ‘1’ until radius

r2 has been reached. As an example, suppose ‘r2-r1 = 2’ then the program has to compute the sum of the areas and

circumferences of three circles with radii r1,r1+1,r2

Remember that the area of a circle equals Pi*r^2 and the circumference equals 2Pi*r.

Set Pi to 3.14

Input:

Two integers r1 and r2 with r1<=r2

Output:

two floats, sum_of_areas and sum_of_circumferences.

Sample Input:

3 4

Sample Output:

78.500000

43.959999

Problem 1017

Title: Product of integers in columns

Description:

In this exercise you have to write a program that can compute the product of the numbers (integers in this case) in a

series of columns.

Input:

The first number of the input, N, describes the number of columns that will follow, then N columns follow. The first

row will contain the first integer of each column. This number M will indicate how many numbers will follow in the

respective column. Note that this means that not each column needs to be of the same length.

Output:

N numbers that represent the product of each column.

Sample Input:

4

3 2 3 4

1 1 1 2

2 3 2 2

3 4 3

2

Sample Output:

6 3 8 24

Problem 1025

Title: Largest common factor and smallest common multiple

Description:

Input two positive integers. Compute their largest common factor and smallest common multiple.

Input:

Input two positive integers.

Output:

largest common factor and smallest common multiple.

Sample Input:

2 3

Sample Output:

1 6

Problem 1060

Title: Sort even integers

Description:

From the input of 10 numbers, sort only the even integers into ascending order.

Print the list with all odd numbers (including 0) in their corresponding place in the input and the even numbers sorted

into ascending order.

Input:

10 integers separated by spaces. (All integers are at most 32 bits)

Output:

An evenly sorted list (even numbers in ascending order, odd numbers unchanged)

Sample Input:

5 3 4 2 1 6 8 7 10 9

Sample Output:

1 3 2 4 5 6 8 7 10 9

Sample Input 2:

11 16 14 12 10 8 6 4 2 1

Sample Output 2:

11 2 4 6 8 10 12 14 16 1

Problem 1030

Title: Precise Division

Description:

8/13=0.615384615384615384615384…

For 8/13, the 5-th digit after the decimal point is 8.

Given three positive integers a, b, and n (all at most 60000), you are asked to compute a/b and print out the n-th digit

after the decimal point.

Input:

a b n (three positive integers)

Output:

The n-th digit after the decimal point of a/b

Sample Input:

8 13 5

Sample Output:

8

WhatsApp us