What did I do wrong(C++)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

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; }

26th Oct 2021, 2:47 PM
notgonnasharethatdata0
5 Answers
+ 2
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).
26th Oct 2021, 8:13 PM
Brian
Brian - avatar
+ 1
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
26th Oct 2021, 4:48 PM
Paul K Sadler
Paul K Sadler - avatar
+ 1
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.
26th Oct 2021, 8:22 PM
Paul K Sadler
Paul K Sadler - avatar
0
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.
26th Oct 2021, 3:33 PM
Paul K Sadler
Paul K Sadler - avatar
0
I'm trying to do this: https://1drv.ms/u/s!Ava17bjtWqmUtUO-GTjEKUbYCl4- (capture of the challenge)
26th Oct 2021, 4:20 PM
notgonnasharethatdata0