#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;

int wordcount_TE(string satz)
{
    int words=1;
    int L=satz.length();
    for(int i=0;i<L;i++)
    {
        if(satz.at(i)==' ')
        {
            words=words+1;
        }
    }
    return words;
}

int wordcount_Ethon(string satz)
{
   int words = count(satz.begin(), satz.end(), ' ');
   return words;
}

void vergleich(string satz)
{
    cout << "Satz ist: \"" << satz << "\"\n"
    << " Phil123 zählt darin " << wordcount_TE(satz)
    << " Wörter, Ethon zählt " << wordcount_Ethon(satz) << '\n';
}

int main()
{
    vergleich("Hallo Welt");
    vergleich("");
    vergleich(" ");
    vergleich("  ");
    vergleich("Hallo  Welt");
    vergleich("Hallo");
    vergleich(" Hallo");
    vergleich("Hallo ");
    vergleich(" Hallo ");    
}