Pagini recente » Cod sursa (job #2810100) | Cod sursa (job #3171384) | Cod sursa (job #534083) | Cod sursa (job #1278237) | Cod sursa (job #351243)
Cod sursa(job #351243)
#include <fstream>
#include <string.h>
#include <ctype.h>
#include <iostream>
using namespace std;
ifstream fin("text.in", ifstream::in);
ofstream fout("text.out", ofstream::out);
void prelucreaza(string stru);
char stri[5000];
int lungimetotal;
int numarcuvinte;
int main()
{
fin.getline(stri,5000);
prelucreaza(stri);
fout << lungimetotal / numarcuvinte;
return 0;
}
void prelucreaza(string stru)
{
//cauta prima litera
bool defolosul;
int q;
q = 0;
defolosul = false;
while (defolosul == false)
{
if (isalpha(stru[q]))
{
defolosul = true;
lungimetotal++;
}
q++;
}
//a gasit prima litera
for (int i = q; i <= stru.length(); i++)
{
if (isalpha(stru[i]))
{
lungimetotal++;
}
else
{
numarcuvinte++;
defolosul = false;
q = i;
while ((defolosul == false) && (q <= stru.length()) )
{
q++;
if (isalpha(stru[q]))
defolosul = true;
lungimetotal++;
}
i = q + 1;
}
}
}