Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives Solve a practical problem Familiarize yourself with C++ standard libraries Practice use of std::vector Introduction In many practical applications we are required to produce
Objectives Solve a practical problem Familiarize yourself with C++ standard libraries Practice use of std::vector Introduction In many practical applications we are required to produce different statistics about input data. For example, we may have to select the minimum, maximum or median element of a sequence. Your task is to write a program that for a sequence of integers provided in a file will find the minimum, the maximum and the median element of that sequence Hints Lecture videos or looking into what functions std::algorithm offers may be helpful Instructions 1. Create directory A4 where you will place your code 2. Create Makefile to automate compilation process of your code. Your main source code file should be named a4.cpp and it should compile to a4 executable. You can directly adopt Makefile from Assignment 3. Write a program that will report the minimum, the maximum and the median element of the input (a) Your program should accept an input file in the format specified below. For example, if invoked like 0 (replace a0 with a4). sequence given the following specification this ./a4 foo.txt your code should produce statistics about the numbers in a file foo.txt. (b) Your program should accept input files in the following format: each line contains one integer greater than zero and the number of integers in a file is always odd and greater than two (c) Your program should print to the standard output a line of three numbers where the first number is the minimum element, the second number is the median element, and the third number is the maximum element. For example, for the following input 10 1 13
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started