Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void vectorMax(vector<int>);
- int main() {
- vector<int> vec{ 1,2,3,6,4,8,7,9,4 };
- vectorMax(vec);
- }
- void vectorMax(vector<int> vec) {
- int max = vec[0];
- for (int i = 0; i < vec.size(); i++) {
- if (vec[i] % 3 == 0 && vec[i] >= max) {
- max = vec[i];
- }
- else if (vec[i] % 3 == 0) {
- cout << "vec[" << i << "] = " << vec[i] << endl;
- }
- else {
- cout << "vec[" << i << "] = ara " << endl;
- }
- }
- cout << max << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement