So i was solving this SoloLearn Ticket office problem with C++. here is problem:
"~You are working on a ticketing system. A ticket costs $10.
The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group.
You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets.
Sample Input:
55
28
15
38
63
Sample Output:
42.5
The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5 ~"
so i did it myself on visual studio with g++.exe (c++20) GCC 11.2.0. i test it with test inputs from SoloLearn and it worked just fine in visual studio. but it outputs large numbers on SoloLearn Platform. what could it be?
first entered number is 1 if its less than 200 it gets replaced by second entered number and so on. if im wrong explain please. lets say smallest entered number 15 it compares to 200 and if its smaller it gets replaced? how does it work exactly ?
when i replayed with that i realised :D it gets replaced so its no longer 200 im so dumb...
i dont get why exactly 200 tho :/ is it just matter of preference ? it can be 100 or 120 or 180 too right?
The input is ages of humans. People can be over 100 years old. Some possibly over 120 years too. The 200 looks like something that is larger than any input we expect. So does 180.
However, if the chaps that are mentioned in the first part of Christian Bible do show up, then 200 is not enough. The safest value is std::numeric_limits<int>::max(). See http://www.cplusplus.com/reference/limits/numeric_limits/
The other approach is to have two loops. The first reads in all the values. The second finds the lowest value. Then you don't need separate initial value for min.