Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- vector <int> vertices;
- int n=12,k, max,min, MaxIndex, MinIndex;
- while (n!=0)
- {
- cin>>n;
- vertices.push_back(n);
- }
- k=vertices.size();
- max=vertices[0];
- min=vertices[0];
- for (int i=1; i<k; i++)
- {
- if(vertices[i]>max)
- {
- max=vertices[i];
- MaxIndex=i;
- }
- if(vertices[i]<min)
- {
- min=vertices[i];
- MinIndex=i;
- }
- }
- cout<<"max = "<<max<<", with index "<<MaxIndex<< endl;
- cout<<"min = "<<min<<", with index "<<MinIndex<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement