Pagini recente » Cod sursa (job #2562647) | Cod sursa (job #1874177) | Cod sursa (job #1183854) | Cod sursa (job #99136) | Cod sursa (job #788324)
Cod sursa(job #788324)
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
int litere, cuvinte;
void Debugwrite();
bool Litera(int curent);
void Getletters();
void Write();
int main()
{
Getletters();
Write();
return 0;
}
void Write()
{
fout << litere/cuvinte;
}
void Getletters()
{
char curent;
bool cuvant = true;
curent = fin.get();
if ( curent != '\n' )
do{
if ( Litera(curent) )
{
litere++;
if ( cuvant == true )
{
cuvinte++;
cuvant = false;
}
}
else
{
cuvant = true;
}
curent = fin.get();
} while ( curent != '\n' );
}
bool Litera(int curent)
{
if ( curent >= 'a' && curent <= 'z' || curent >= 'A' && curent <= 'Z')
return true;
return false;
}
void Debugwrite()
{
cout << "Litere: " << litere << '\n' << "Cuvinte: " << cuvinte;
cout << "\nImpartire: " << litere/cuvinte;
}