Pagini recente » Cod sursa (job #1830888) | Cod sursa (job #11073) | Cod sursa (job #1267439) | Cod sursa (job #1639270) | Cod sursa (job #20358)
Cod sursa(job #20358)
#include <stdio.h>
#include <cctype>
using namespace std;
int main(){
FILE* f = fopen("text.in","r");
long long totalchars = 0;
long long nrcuv = 0;
char c;
char state = 'n';
while(fscanf(f,"%c",&c) != EOF){
if(isalpha(c))
++totalchars;
switch(state){
case 'n':
if(isalpha(c)){
state = 'c';
++nrcuv;
}
break;
case 'c':
if(!isalpha(c)){
state = 'n';
}
}
}
fclose(f);
f = fopen("text.out","w");
fprintf(f,"%d",(totalchars / nrcuv));
fclose(f);
}