Mai intai trebuie sa te autentifici.
Cod sursa(job #479429)
Utilizator | Data | 24 august 2010 00:59:29 | |
---|---|---|---|
Problema | Text | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.78 kb |
// Afla lungimea medie a cuvintelor din text
#include <fstream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int MAXSIZE = 1024;
int main() {
ifstream fin("text.in");
ofstream fout("text.out");
char* alfabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
char* buffer = new char[MAXSIZE];
int nr_w=0, nr_l=0;
while (!fin.eof()) {
fin >> buffer;
for(int i=0; i<(int)strlen(buffer) ; i++) {
if (strchr(alfabet,buffer[i])==NULL) {
i++;
while ((strchr(alfabet,buffer[i])==NULL)&&(i<=(int)strlen(buffer)))
i++;
if (i<(int)strlen(buffer)) {
nr_w+=1;
nr_l+=1;
}
}
else {
if (i==0)
nr_w++;
nr_l+=1;
}
}
}
fout << nr_l/nr_w;
fin.close();
fout.close();
return 0;
}