Commit d8b91a79 authored by Michael's avatar Michael

michael.davityan:exercise_04_19

parent 8072b1eb
Pipeline #23075645 passed with stage
in 1 minute 24 seconds
dbg: debug/exercise_04_19
debug/exercise_04_19: debug/exercise_04_19.o
g++ -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_19.o: debug/exercise_04_19.s
g++ -c -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_19.s: debug/exercise_04_19.ii
g++ -S -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_19.ii: exercise_04_19.cpp
g++ -E -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_19.ii: | debug
debug:
mkdir -p debug
clean:
rm -rf debug *.ii *.s *.o *.out .gitignore
test: debug/exercise_04_19
./debug/exercise_04_19 < test1.in > test1.out || echo "Test 1 is executing..."
diff test1.out test1.expected && echo PASSED || echo FAILED
.PRECIOUS: exercise_04_19.ii exercise_04_19.s
.SECONDARY: exercise_04_19.ii exercise_04_19.s
#include <iostream>
#include <climits>
#include <unistd.h>
int
main()
{
int count = 1;
int firstLargest = INT_MIN;
int secondLargest = INT_MIN;
while (count <= 10) {
if (::isatty(STDIN_FILENO)) {
std::cout << "Insert integer" << count << ": ";
}
int number;
std::cin >> number;
if (firstLargest < number) {
secondLargest = firstLargest;
firstLargest = number;
}
if (firstLargest != number) {
if (secondLargest < number) {
secondLargest = number;
}
}
++count;
}
std::cout << "The most two largest numbers is " << secondLargest
<< ", " << firstLargest << std::endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment