Pagini recente » Cod sursa (job #1682098) | Cod sursa (job #1316614) | Cod sursa (job #1710299) | Cod sursa (job #244498) | Cod sursa (job #584025)
Cod sursa(job #584025)
#include <stdio.h>
using namespace std;
int main(){
FILE *ipf = fopen("text.in", "r");
FILE *opf = fopen("text.out", "w");
bool este = false;
char c;
int charCount = 0, wordCount = 0;
while (!feof(ipf)){
fscanf(ipf, "%c", &c);
//fprintf(opf, "%c", c);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
if (!este){
este = true;
charCount++;
wordCount++;
}
else
charCount++;
else
if (este){
este = false;
//fprintf(opf, "\n");
}
else;
}
fprintf(opf, "%d", charCount/wordCount);
fclose(ipf);
fclose(opf);
return 0;
}