Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- using namespace std;
- void my_swap(int & a, int & b){
- int temp = b;
- b = a;
- a = temp;
- }
- //find min value
- //int find_min(const vector<int> &v, const int & left, const int & right)
- int find_min(const vector<int> & v, const int & left, const int & right){
- int smallestAmt = v[left];
- for(size_t i = left; i <= v.size()-1; ++i){
- //first if checks others when exception is made
- if(v[left] > v[i]){
- smallestAmt = v[i];
- //start looping with new value
- for(size_t i = smallestAmt; i <= v.size()-1; ++i){
- //second exception made; only three can be made total
- if(v[smallestAmt] > v[i]){
- smallestAmt = v[i];
- //loop again
- for(size_t i = smallestAmt; i <= v.size()-1; ++i){
- if(v[smallestAmt] > v[i]){
- smallestAmt = i;
- return smallestAmt;
- }
- }
- //third
- return smallestAmt;
- }
- }
- //second
- return smallestAmt;
- }
- }
- //if first; or if the starting value is the smallest
- cout << "Smallest is " << smallestAmt;
- return smallestAmt;
- }
- void selection_sort(vector<int> & v){
- }
- int main()
- {
- //ze vectorz
- vector<int>v;
- v.push_back(3);
- v.push_back(1);
- v.push_back(4);
- v.push_back(2);
- cout << find_min(v, 2, v.size());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment