Pagini recente » Cod sursa (job #1611694) | Cod sursa (job #1227450) | Cod sursa (job #2664402) | Cod sursa (job #2585862) | Cod sursa (job #28186)
Cod sursa(job #28186)
#include<stdio.h>
#include<iostream.h>
char c;
int lit,cuv,space;
int total;
int main(void) {
FILE *in=fopen("text.in","rt"),*out=fopen("text.out","w+");
while(fscanf(in,"%c",&c)!=EOF){
if((c>=65 && c<=90) || (c>=97 && c<=122)) {
lit=lit+1;
space=0;
}
else if(c==32 || c==33 || c==63 || c==46 || c==44) space=1;
if (space) cuv=cuv+1;
}
//cuv=cuv+1;
total=(float)lit/cuv;
cout<<"litere: "<<lit<<endl;
cout<<"cuvinte: "<<cuv<<endl;
cout<<"litere/cuvinte: "<<total<<endl;
fprintf(out,"%d",total);
}