How to do this question without using class?

I have not studied class. Is there any way to do this question without using structure or class? How will i print integers if i print names in lexicographical order?

@aditikandhway you can use the pair<string, int> datatype to store the name-salary pairs and sort them using the inbuilt sort function and custom compare function. Let me know if you need any help with that.

Ok… But how to sort pairs lexicographical in terms of name only…?

@aditikandhway firstly make an array or vector of pair<string, int>, then sort that container using sort() function.
You can access string part by arr[i].first and int part can be accessed by arr[i].second
in sort function you will get 2 pairs so it will look like

bool myComp(pair<string, int> p1, pair<string, int> p2) {
   ...do something
}

Can I use array instead of vector.

@aditikandhway yes you can use array as well, syntax will remain the same.

What will be the type for the array if i use pair inside the array?

@aditikandhway syntax:
pair<string, int> arr[n]; I hope it is clear now

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.