Pagini recente » Cod sursa (job #2417164) | Cod sursa (job #702354) | Cod sursa (job #1575328) | Cod sursa (job #1818408) | Cod sursa (job #783642)
Cod sursa(job #783642)
#include <iostream>
#include <cstdio>
#include <fstream>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
bool CharCheck(char character);
int nrc = 1, nrtl = 0;
int main()
{
int thischar = fin.get();
while (thischar != '\n')
{
if ( CharCheck(thischar) )
nrtl++;
else
if ( thischar == ' ' || thischar == '-')
nrc++;
thischar = fin.get();
}
cout << nrtl << ' ' << nrc << '\n';
cout << nrtl/nrc << '\n';
return 0;
}
bool CharCheck(char character)
{
static bool firstword = false;
if (firstword == false)
if ( character == ' ' || character == '-' )
{
nrc --;
}
if ( (int)character >= 97 && (int)character <= 122 )
{
firstword = true;
return true;
}
if ( (int)character >= 65 && (int)character <= 90 )
{
firstword = true;
return true;
}
return false;
}