Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int max_value(list<int> a) {
- int max_val;
- int i;
- max_val = -1; // assume all elements are positive
- for (i = 0; i < #a; ++i) {
- if (a[i] > max_val) {
- max_val = a[i];
- }
- }
- }
- int main() {
- list<int> a;
- a = [4, 10, 40, 23, 85, 2];
- printi(max_value(a));
- return 0;
- }
- output: 85
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement