Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

idea for programming in c language (data structure)

+16 votes
asked Jul 13, 2021 by paulo magalhaes (1,440 points)
It has a lot of text in the statement for little problem.


The condition you want to count is the number of guys who are already in the right place in the queue.


There are two things then:

    determine the right place in the queue, as the place they are is well known :)

Example 1 (yours):

100 80 90

In order it would be 100 90 80

looking at the two side by side

100 80 90 (original)
100 90 80 (in descending order)


And only one matches: 2 will change places


Example 2 (yours):

100 120 30 50


100 120 30 50
120 100 50 30


And none is in place: 4 will change


Example 3 (yours):

100 90 30 25
100 90 30 25


And these are in the right order



So just sort the notes in descending order, obviously on another vector, and count how many are equal in position.


Of course, equal grades will cause confusion: in general, guys with the same grade should be seen in order of arrival, but there's no way to do that with these data....

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.