Answer to Question #240713 in C++ for Navaneeth

Question #240713
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.
1
Expert's answer
2021-09-22T08:48:44-0400
#include <iostream>
using namespace std;


int main(){
	int N;
	cin>>N;
	int* student =new int[N];


	for(int i=0; i<N; i++){
		cin>>student[i];
	}
	cout<<"\n";
	for(int i=0; i<N; i++){
		int count = 0;
		for(int j=0; j<i; j++){
			if(student[j]>= student[i]){
				count++;
			}
		}
		cout<<count<<"\n";
	}
	delete[] student;


	cin>>N;


	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS