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.
Input1- an integer N, which denotes the number of students present
Input2- An array of size N, denoting the problem solving capacity of the students.
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.
#include<iostream>
using namespace std;
int main(){
int student[] = {4 , 9 , 5 , 3 , 2 , 10};
cout<<"Output:\n";
for(int i=0; i<6; i++){
int count = 0;
for(int j=0; j<i; j++){
if(student[j]>= student[i]){
count++;
}
}
printf("%d, ",count);
}
}
Comments
Leave a comment