What did I do wrong(C++)? | Sololearn: Learn to code for FREE!


What did I do wrong(C++)?

It says Expected output: 100 Your output:100 and it's wrong... my code is this: #include <iostream> using namespace std; int main() { int self = 20; int pers1 = 20; int pers2 = 20; int pers3 = 20; int pers4 = 20; int sum = self + pers1 + pers2 + pers3 + pers4; cout << sum ; return 0; }

10/26/2021 2:47:00 PM


5 Answers

New Answer


Paul K Sadler I'd say skip step 2, as there is no need to sort. Just count of how many names are less than or equal to yours (without adding your own name to the list).


Ok, I recognize that challenge in Sololearn. The issue is that you need to include the number of agents in your time tabulation. Also your position in line since people are helped alphabetically. So if your name starts with ZZZ(last alphabetically) you are in line with 5 people then it will take 100 minutes if there is one agent. But if there are 3 agents it will take 40 minutes, 5 agents 20 minutes. You need to take input in this challenge. The input is your name, the number of agents and then the name of people in line. So your program needs to 1. Take the 3 inputs 2. Sort the list of people in line(don't forget to include yourself) 3. Determine your place in line 4. Using the above determine how long it will take given your place in line


Hey Brian that's a good idea. I did the sort and then returned the index of my entry. I like it your way and I think it is more efficient.


notgonnasharethatdata0 5 * 20 is 100. The output is what you coded. It seems that what you intended to output is not what you coded. Can you describe what you are trying to achieve? Is there more to the specificaton? look it over carefully to ensure you have included all requested aspects.


I'm trying to do this: https://1drv.ms/u/s!Ava17bjtWqmUtUO-GTjEKUbYCl4- (capture of the challenge)