Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. string findMin(string arr[], int size) {
  7. string smallest;
  8. smallest = arr[0];
  9. for (int i = 0; i < size; i++){
  10. if (arr[i] < smallest){ // Flip < to > to find largest
  11. smallest = arr[i];
  12. }
  13. }
  14. return smallest;
  15. }
  16.  
  17. int main() {
  18.  
  19. string A[7] = { "MBA", "ME", "Psy", "EE", "CS", "CE", "Bio" };
  20.  
  21. cout << findMin(A, 7);
  22.  
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement