Commit 89f1a6c7 authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_04_19' into 'master'

Exercise_04_19, Version1 See merge request bpcarm/trainings2017!1147
parents 6df426fb 642099e9
exercise_04_19: exercise_04_19.o | .gitignore
g++ $^ -o $@
exercise_04_19.ii: exercise_04_19.cpp
g++ -E $^ -o $@
exercise_04_19.s: exercise_04_19.ii
g++ -S $^ -o $@
exercise_04_19.o: exercise_04_19.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_04_19" > $@
clean:
rm *.ii *.s *.o *.out exercise_04_19 .gitignore
test: exercise_04_19
@./exercise_04_19 < test.in > test.out
@diff test.out test.expected > /dev/null 2>&1 && echo PASSED || echo FAILED
test1: exercise_04_19
@./exercise_04_19 < test1.in > test1.out
@diff test1.out test1.expected > /dev/null 2>&1 && 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>
int
main()
{
int counter = 1;
int number;
std::cout << "Enter 10 numbers: ";
int largest = INT_MIN;
int secondLargest = INT_MIN;
while (counter <= 10) {
std::cin >> number;
if (number > largest) {
secondLargest = largest;
largest = number;
} else if(number > secondLargest) {
secondLargest = number;
}
++counter;
}
std::cout << "The largest value is: " << largest << std::endl;
std::cout << "The second largest value is: " << secondLargest << std::endl;
return 0;
}
Enter 10 numbers: The largest value is: 666
The second largest value is: 344
Enter 10 numbers: The largest value is: -1
The second largest value is: -2
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