Pagini recente » Cod sursa (job #1465365) | Cod sursa (job #1521174) | Cod sursa (job #3255025) | Cod sursa (job #1627216) | Cod sursa (job #28191)
Cod sursa(job #28191)
#include<stdio.h>
#include<iostream.h>
#include<string.h>
char c;
int lit,cuv,space,i=0,j=0,k,l,pos=1;
int total;
int main(void) {
char delims[20]={'.',',','!','?','-',' ','\n'},*ptr;
FILE *in=fopen("text.in","rt"),*out=fopen("text.out","w+");
while(fscanf(in,"%c",&c)!=EOF){
j=j+1;
for(k=0;k<=6;k++){
if(c==delims[k]){
if (j-pos>1){
cuv=cuv+1;
}
pos=j;
}
else if((c>=65 && c<=90) || (c>=97 && c<=122)) lit=lit+1;
}
}
lit=lit/7;
cuv=cuv-1;
total=(float)lit/cuv;
cout<<"litere: "<<lit<<endl;
cout<<"cuvinte: "<<cuv<<endl;
cout<<"litere/cuvinte: "<<total<<endl;
fprintf(out,"%d",total);
}