Pagini recente » Cod sursa (job #2153159) | Cod sursa (job #1653574) | Cod sursa (job #1302646) | Rating Dave Wong (dwsc) | Cod sursa (job #2437913)
// Example program
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
ifstream f("text.in");
ofstream o("text.out");
int avg,len,wordc;
char *pok,text[1024*1024 +1];
int main()
{
f.getline(text,1024*1024 +1);
//cin.get();
pok=strtok(text," ,.-_;:()!?`1234*@#$%^&567890'[]{}=+\|/<>");
while(pok!=NULL)
{
len+=strlen(pok);
wordc++;
pok=strtok(NULL," ,.-_;:()!?`1234*@#$%^&567890'[]{}=+\|/<>");
}
avg=len/wordc;
//cout<<len<<wordc;
o<<avg;
return 0;
}