Pagini recente » Cod sursa (job #3232859) | Cod sursa (job #2311003) | Cod sursa (job #1789169) | Cod sursa (job #1132996) | Cod sursa (job #2288287)
#include <fstream>
using namespace std;
int main()
{
int NumarLitere = 0, NumarCuvinte = 0;
char c, lastchar = -1;
ifstream fin;
ofstream fout;
fin.open("text.in");
while (fin.get(c))
{
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;
}
if (lastchar >= 65 && lastchar <= 90 || lastchar >= 97 && lastchar <= 122)
NumarCuvinte++;
fin.close();
fout.open("text.out");
fout << NumarLitere / NumarCuvinte;
fout.close();
return 0;
}