Input Format The first line contains a single integer N denoting the size of array. The second line contains N space-separated integers denoting the elements of the array. Constraints 1 <= N <= 100 0 <= A[i] <= 100 Output Format Print all the leaders. Sample Input 0 6 16 17 4 3 5 2 Sample Output 0 17 5 2 Sample Input 1 5 5 4 3 2 1 Sample Output 1 5 4 3 2 1
Answers
Answered by
1
Explanation:
the array has size to only hence possible split can be only three or four hands the answer is 4- 3=1
Answered by
0
The first line contains a single integer N denoting the size of the array. The second line contains N space-separated integers denoting the elements of the array. Constraints 1 <= N <= 100 0 <= A[i] <= 100
SOURCE CODE:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num, *arr,*arr2,i;
scanf("%d", &num);
arr = (int*) malloc(num * sizeof(int));
for(i = 0; i < num; i++) {
scanf("%d", arr + i);
}
arr2 = (int*) malloc(num * sizeof(int));
for(i=1;i<=num;i++)
{
arr2[i-1] = arr[num-i];
}
for(i = 0; i < num; i++)
printf("%d ", *(arr2 + i));
return 0;
}
Explanation:
- In the main function, the variable and pointers are initialised (num, *arr1, *arr2).
- After which, the malloc function is used with pointers arr1 and arr2.
- To dynamically allocate a single huge block of memory with the required size in C, use the "malloc" or "memory allocation" method. It gives back a void pointer that can be cast into any other kind of pointer.
- Using the function, it will start from the initial value till the value entered and give the appropriate output.
- After the execution, it will print the output with the help of a pre-defined print function.
#SPJ3
Similar questions