hè ušer för the number of 7/Given a string, take n input from students and then put them in the declared vector. Sort the list in alphabetical order. If two students have same name the student with the smaller rollnumber comEs first. Assume only one word inputs. Finally input the sorted name and rollnumber on the scre // // Example if there are two students named Ali. The one having 2 3 rollnumber 1 will come before the one having rollnumber 2. 4 // TO-DO // Part 1 for vector inputing. // Part 2 for sorting and Printing on screen (sorted name with 7 8 their corresponding rollnumbers)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question
100%

in c++. without using "sort" function.

main.cpp
//Given a string, take n input from the user for the number of
students and then put them in the declared vector. Sort the list
in alphabetical order. If two students have same name the student
with the smaller rollnumber comes first. Assume only one word
inputs. Finally input the sorted name and rollnumber on the screen
1
2
//
// Example if there are two students named Ali. The one having
rollnumber 1 will come before the one having rollnumber 2.
3
4
5
//
// Part 1 for vector inputing.
// Part 2 for sorting and Printing on screen (sorted name with
their corresponding rollnumbers)
TO-DO
7
8
Transcribed Image Text:main.cpp //Given a string, take n input from the user for the number of students and then put them in the declared vector. Sort the list in alphabetical order. If two students have same name the student with the smaller rollnumber comes first. Assume only one word inputs. Finally input the sorted name and rollnumber on the screen 1 2 // // Example if there are two students named Ali. The one having rollnumber 1 will come before the one having rollnumber 2. 3 4 5 // // Part 1 for vector inputing. // Part 2 for sorting and Printing on screen (sorted name with their corresponding rollnumbers) TO-DO 7 8
10
#include <iostream>
11
#include <vector>
12
#include <string>
13
14
struct student
{
int rollnumber;
15
16
std::string name;
};
17
18
19
20
21
int main() {
22
23
std::vector<student> list;
24
25
26
Transcribed Image Text:10 #include <iostream> 11 #include <vector> 12 #include <string> 13 14 struct student { int rollnumber; 15 16 std::string name; }; 17 18 19 20 21 int main() { 22 23 std::vector<student> list; 24 25 26
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning