Pagini recente » Cod sursa (job #766032) | Cod sursa (job #1097598) | Cod sursa (job #1134252) | Cod sursa (job #1328071) | Cod sursa (job #351245)
Cod sursa(job #351245)
#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 << (int)lungimetotal / numarcuvinte;
return 0;
}
void prelucreaza(string stru)
{
bool defolosul;
int q = 0;
while (!isalpha(stru[q]))
q++;
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;
}
}
}