Cod sursa(job #1167695)
| Utilizator | Data | 5 aprilie 2014 18:57:37 | |
|---|---|---|---|
| Problema | Text | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include<cstdio>
#include<cstring>
int l,i,j,nr,nc;
char s[2000100],*p;
FILE *f,*g;
int main(){
f=fopen("text.in","r");
g=fopen("text.out","w");
fgets(s,3000000,f);
l=strlen(s);
p=strtok(s," -,.!?:");
while(!NULL){
if(*p=='\n')
break;
if((*p>'z'||*p<'a')&&(*p<'A'&&*p>'Z')){
p=strtok(NULL," -,.!?:");
continue;
}
nr++;
i=0;
while((*(p+i)>='a'&&*(p+i)<='z')||(*(p+i)>='A'&&*(p+i)<='Z')){
nc++;
i++;
}
p=strtok(NULL," -,.!?:");
}
fprintf(g,"%d",nc/nr);
fclose(f);
fclose(g);
return 0;
}
