Pagini recente » Cod sursa (job #637842) | Cod sursa (job #2182750) | Cod sursa (job #2435154) | Cod sursa (job #2470580) | Cod sursa (job #1472941)
#include <fstream>
using namespace std;
int main()
{
FILE *f, *g;
f = fopen("text.in","r");
g = fopen("text.out","w");
char c;
int cuvinte = 0;
int state = 0;
int litere = 0;
while (fscanf(f,"%c",&c) != EOF){
if ((('a' <= c && c <= 'z') || ( 'A' <= c && c <= 'Z' )) && state == 0)
state = 1;
else if ((('a' <= c && c <= 'z') || ( 'A' <= c && c <= 'Z' )) && state == 1)
state = 2;
else if (!(('a' <= c && c <= 'z') || ( 'A' <= c && c <= 'Z' )) && state == 2)
state = 0;
if (state == 1){
cuvinte++;
litere++;
}else if (state == 2){
litere++;
}else if (state == 0) {
continue;
}
}
fprintf(g,"%d %d %d",litere/cuvinte, litere , cuvinte);
fclose(f);
fclose(g);
}