Write two generic functions (overloaded) named area(). Create function template for the first area() function that it is able to receive the radius of a circle as its parameter and returns half of the calculated area of circle as of same data type. Similarly, create function template for the second area() function that it is able to receive two parameters as length and width of a rectangle and returns the triple of the calculated area of rectangle as of same data type.
Write a generic function common() that calculates the double of each element in the array and returns the value which is most frequent in an array. The function arguments should be the address of the array and its size. Make this function into a template so it will work with an array of any data type i.e. int, long, double.
code in Question #175894 gives result:12x^4 + 9x^3 + -5x^2 - 1x - 1 but 12x^4 + 9x^3 - 5x^2 - x - 1 is desired output.
how to get desired result .
input =
5
0 -2
3 6
4 7
1 -3
2 -1
5
0 1
1 2
2 -4
3 3
4 5to write a C++ program which will read the given text file and will produce an
output text file with the name “Email_IDs” which must contain the valid email addresses of
the students mentioned in the input text file.
Bubble sort is an algorithm to sort a 1D array in ascending order. Firstly, explain bubble sort
and then write a C++ program by using the concept of templates to sort and display any type
of 1D array.
Write a C++ program to ask the user to enter the size and elements of an 1D array. Then ask
the user to enter an index and display the element at that index. If user enters a negative
index, then throw a string exception stating an invalid index and display the element at index
0. If the user enters an index greater than the maximum possible index, then throw an integer
exception and display the last possible index along with element at last index. If the user
enters a correct index, then simply display the element at that index.
M, N = input().split()
M, N = int(M), int(N)
matrix = []
for _ in range(M):
row = [int(x) for x in input().split(' ')]
matrix.append(row)
K = int(input())
values = matrix[0][:-1] + [x[-1] for x in matrix][:-1] + matrix[-1][::-1][:-1] + [x[0] for x in matrix][::-1][:-1]
values = values[-K:] + values[:-K]
output = matrix
idxs = [(0, j) for j in range(N)][:-1] + [(i, N - 1) for i in range(M)][:-1] + [(M - 1, j) for j in range(N)][::-1][:-1] + [(i, 0) for i in range(M)][::-1][:-1]
idx = 0
for i, j in idxs:
output[i][j] = values[idx]
idx += 1
print(output)
input:4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
output should be like this:
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4 can you please make code
integers = [int(number) for number in input().split()]
K = int(input())
triplets = []
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if a+b+c == K:
triplets.append(tuple((a,b,c)))
sorted_triplets=[]
for tripl in triplets:
item = sorted(tripl)
sorted_triplets.append(item)
triplets= sorted(sorted_triplets)
if len(triplets)!=0:
for triplet in triplets:
triplet=sorted(triplet)
tuple_a=tuple(triplet)
print(tuple_a)
input:0 1 2 3 5 7 13 17 19 19
22
output should be like this :
(0, 3, 19)
(0, 5, 17)
(1, 2, 19)
(2, 3, 17)
(2, 7, 13)
You are given three numbers. Check if any of the numbers exist in the range from 10 to 20 (including 10 and 20).
Discuss the phases of warehouse architecture?