Pagini recente » Istoria paginii runda/dacanuintratiluati3 | Cod sursa (job #562533) | Cod sursa (job #1261026) | Cod sursa (job #1456493) | Cod sursa (job #2288236)
#include <fstream>
using namespace std;
int main()
{
int NumarLitere = 0, NumarCuvinte = 0;
char c, lastchar = -1;
ifstream fin;
ofstream fout;
fin.open("text.in", in);
fin >> c;
while ((fin.rdstate() & ifstream::eofbit) == 0)
{
if (c >= 65 && c <= 90 || c >= 97 && c <= 122)
NumarLitere++;
if (!(c >= 65 && c <= 90 || c >= 97 && c <= 122) && (lastchar >= 65 && lastchar <= 90 || lastchar >= 97 && lastchar <= 122))
NumarCuvinte++;
lastchar = c;
fin >> c;
}
if (lastchar >= 65 && lastchar <= 90 || lastchar >= 97 && lastchar <= 122)
NumarCuvinte++;
fin.close();
fout.open("text.out", out);
fout << NumarLitere / NumarCuvinte;
fout.close();
return 0;
}