0

To find out the exact time to step out of the office with the license

You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now, and they can each see one customer at a time. How long will it take for you to walk out of the office with your new license? Task Given everyone's name that showed up at the same time, determine how long it will take to get your new license. Input Format Your input will be a string of your name, then an integer of the number of available agents, and lastly a string of the other four names separated by spaces. Output Format You will output an integer of the number of minutes that it will take to get your license. Sample Input 'Eric' 2 'Adam Caroline Rebecca Frank' Sample Output 40

4th Aug 2020, 7:34 AM
Saiteja Alasyam
Saiteja Alasyam - avatar
5 Respostas
+ 7
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool compare(string a, string b) { return a<b; } int main() { vector<string> people; string name; string my_name; getline(cin, my_name); people.push_back(my_name); string agents_get; getline(cin, agents_get); int agents = stoi(agents_get); string others; getline(cin, others); for(char c : others) { if(c==' ') { people.push_back(name); name=""; } if(c!=' ')name+=c; } people.push_back(name); sort(people.begin(),people.end(), compare); int my_index; for(unsigned int i=0; i<people.size(); i++) { if(people[i]==my_name) my_index=i; } cout << (my_index/agents+1)*20; return 0; }
4th Aug 2020, 8:17 AM
Orchiiik
Orchiiik - avatar
+ 4
Attempt pls
4th Aug 2020, 7:38 AM
Nilesh
Nilesh - avatar
+ 1
Saiteja Alasyam that's a code coach question here at sololearn, we are not supposed to solve it for you. But we can find mistakes in your code, so just like Nilesh said you should always post your attempt with question like these
4th Aug 2020, 7:40 AM
Arsenic
Arsenic - avatar
0
Help me
4th Aug 2020, 7:39 AM
Saiteja Alasyam
Saiteja Alasyam - avatar
0
#include <iostream> #include<cstring> using namespace std; class License { private : int time; public: string name; int agents; string others; int l=0; void getdata() { getline(cin,name); cin>>agents; getline(cin,others); } void putdata() { int i,k,j; max='A' k=others.length (); for(i=0;i<k;i++) { if(others[i]<='Z' && others[i]>='A') { if(name[0]=max) l=1; else if } } time=(l*20)/agents; cout<<time; } }; int main() { License o1; o1. getdata(); o1. putdata(); }
4th Aug 2020, 7:46 AM
Saiteja Alasyam
Saiteja Alasyam - avatar