Question 1
Revisit Later
Compil
How to Attempt?
Placement Season Begins
The placement season has begun in a college. There are N number of students standing outside an interview room in a line. It is given that a person who goes in first has higher chances of getting selected.
Each student has a number associated with them known as the problem solving capability (PSC). The higher the capability, the higher the chances of selection. Now, each student wants to know the number of students ahead of him/her who have more problem-solving capability than him/her.
Find this number for each student.
Input Specification:
input1: An integer N. which denotes the number of students present. input2: An array of size N, denoting the problem-solving capability of the students
#include <stdio.h>
#define SIZE 100
int main() {
int n, i, j;
int PSC[SIZE];
int ahead[SIZE];
scanf("%d", &n);
for (i=0; i<n; i++) {
scanf("%d", &PSC[i]);
ahead[i] = 0;
}
for (i=0; i<n; i++) {
for (j=0; j<n; j++) {
if (PSC[i] < PSC[j]) {
ahead[i]++;
}
}
}
for (i=0; i<n; i++) {
printf("%d ", ahead[i]);
}
printf("\n");
return 0;
}
Comments
Leave a comment