Pagini recente » Cod sursa (job #2045903) | Cod sursa (job #2354501) | Cod sursa (job #1629104) | Cod sursa (job #411755) | Cod sursa (job #212030)
Cod sursa(job #212030)
#include <fstream>
#include <string>
using namespace std;
bool isText(char txt, bool mode = false) {
if((txt >= 65 && txt <= 90) || (txt >= 97 && txt <= 122)) return 1;
return 0;
}
int main() {
ifstream fin("text.in");
ofstream fout("text.out");
string text = "";
int lCount = 0;
int wCount = 0;
getline(fin, text);
for(int i = 0; i < text.size(); i++) {
// Count the letters
if(isText(text[i])) lCount++;
// Count the words
if(i > 1 && (text[i] == 32 || text[i] == 44 || text[i] == 45 || text[i] == 33 || text[i] == 63 || text[i] == 46) && isText(text[i-1], true)) wCount++;
}
fout<<lCount / wCount;
return 0;
}