Cod sursa(job #1333891)
Utilizator | Data | 3 februarie 2015 18:12:23 | |
---|---|---|---|
Problema | Text | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin ("text.in");
ofstream fout ("text.out");
string s;
int main(){
int total=0, words=0;
bool ok;
getline (fin, s);
s[s.size()]=' ';
for(int i=0; i<s.size(); i++){
if(isalpha(s[i])) total++, ok= true;
if(!isalpha(s[i+1]) && ok) words++, ok= false;
}
if(words==0) return 0;
fout << total/words;
return 0;
}