Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a function which takes arugements of strings
- // and returns the lowest lexiographic one
- #include <iostream>
- #include <tuple>
- using namespace std;
- string myArray[4] = { "12345678", "01", "12345", "012" };
- int n;
- pair <string, int> minStr(string arr[], int size )
- {
- string minString = arr[0];
- int position = 0;
- for(int i = 1; i<size; i++)
- {
- if(arr[i] < minString)
- {
- minString = arr[i];
- position = i;
- }
- }
- return { minString, position };
- }
- int main()
- {
- string s;
- int i;
- n = sizeof(myArray) / sizeof(myArray[0]);
- tie(s, i) = minStr(myArray, n);
- cout << s << " " << i << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement