Pagini recente » Cod sursa (job #2555071) | Cod sursa (job #3255258) | Cod sursa (job #153551) | Cod sursa (job #2822780) | Cod sursa (job #730189)
Cod sursa(job #730189)
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
FILE * iFile;
FILE * oFile;
int main()
{
iFile = fopen("text.in", "r");
oFile = fopen("text.out", "w");
long long int cuv, chars;
char c, cprev;
chars = 0;
cuv = 0;
fscanf(iFile, "%c", &c);
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <='Z'))
chars++;
cprev = c;
while(!feof(iFile))
{
fscanf(iFile, "%c", &c);
if(c == '-' && ((cprev >= 'a' && cprev <= 'z') || (cprev >= 'A' && cprev <='Z')))
cuv++;
if(c == ' ')
cuv++;
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <='Z'))
chars++;
cprev = c;
}
fprintf(oFile, "%lld", chars/cuv);
fclose(iFile);
fclose(oFile);
return 0;
}