Advertisement
Tavxela

Untitled

Nov 16th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. void vectorMax(vector<int>);
  7.  
  8.  
  9. int main() {
  10. vector<int> vec{ 1,2,3,6,4,8,7,9,4 };
  11. vectorMax(vec);
  12. }
  13.  
  14. void vectorMax(vector<int> vec) {
  15. int max = vec[0];
  16. for (int i = 0; i < vec.size(); i++) {
  17. if (vec[i] % 3 == 0 && vec[i] >= max) {
  18. max = vec[i];
  19.  
  20. }
  21. else if (vec[i] % 3 == 0) {
  22. cout << "vec[" << i << "] = " << vec[i] << endl;
  23. }
  24. else {
  25. cout << "vec[" << i << "] = ara " << endl;
  26. }
  27. }
  28. cout << max << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement