/*
 * Lösung für Übung 3.8.1 - Von while zu for übersetzen
 */
#include <iostream>
#include <string>
#include <vector>

int main()
{
  std::vector<std::string> movieQuotes = {
    "May the Force be with you",
    "I'm the king of the world",
    "I'll be back",
    "E.T. phone home" };
  std::string shortestQuote;
  int indexOfShortestQuote = -1;

  for (int i=0; i < movieQuotes.size(); i++)
  {
    std::string quote = movieQuotes.at(i);
    std::cout << "Checking: " << quote << std::endl;
    if (indexOfShortestQuote == -1 
      || quote.size() < shortestQuote.size())
    {
      shortestQuote = quote;
      indexOfShortestQuote = i;
    }
  }
  std::cout << "Shortest quote found at index "
            << indexOfShortestQuote << ": "
            << shortestQuote << std::endl;
  return 0;
}
