Pagini recente » Cod sursa (job #3269872) | Cod sursa (job #1864311) | Cod sursa (job #620815) | Istoria paginii utilizator/lilianagalbenu | Cod sursa (job #470175)
Cod sursa(job #470175)
/**
*
* Info: from Infoarena
* Title: Text
* Author: Lazar Pavel
*
**/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main(){
FILE *fin = fopen("text.in","r");
FILE *fout = fopen("text.out","w");
char line[80];
char ch;
int chars = 0;
int words = 0;
int i;
int start = 0;
int finis = 0;
while( fgets(line,80,fin) != NULL ){
for( i = 0; i < strlen(line); i++ ){
ch = line[i];
if( tolower(ch) > 96 && tolower(ch) < 123 ){
chars++;
if( start == 0 ){
start = 1;
finis = 0;
}
}else{
if( start == 1 && finis == 0 ){
finis = 1;
start = 0;
words++;
}
}
}
}
fprintf(fout,"%d", (int)chars/words );
fclose(fin);
fclose(fout);
return 0;
}