C++ project in progress
Not really a question, just sharing my thought process on solving a problem. I'm trying to finish the end-of-Module project for the "Data Types, Arrays, and Pointers" module of the C++ course. Problem can be found at: https://www.sololearn.com/learning/eom-project/1051/904 My solution in Python: https://code.sololearn.com/cJuCR3qjY5qo My solution in C++ (in progress): https://code.sololearn.com/crl12QTk2Ocu // 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. I worked out the solution in Python, just to make sure I knew what I was trying to solve, and to get an idea of how to approach it in C++. Python solution in four lines: Ages = list(map(int, input().split())) Discount = min(Ages) / 100 Total = 50 - (50 * Discount) print(Total) In one line: print(50 - (50 * (min(list(map(int,input().split())))/100))) So, to do this in C++, at least for this project, I have to assume there is no min() function, which means I'll have to use a for loop to do the job. Also, no map() function. Converting the values from string to int will have to be done with a for loop also. This is my C++ solution, or at least the commentary: #include <iostream> using namespace std; int main() { // convert the string input into a list // convert the string objects into int objects // isolate the min int object // do the math: 50 - (50 * (min / 100)) return 0; } I know this should be a simple job, but even looking at the C's these days gives me a bit of a headache.