Pagini recente » Cod sursa (job #2971594) | Cod sursa (job #1205710) | Cod sursa (job #2739178) | Cod sursa (job #2061529) | Cod sursa (job #1459227)
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
ifstream in("text.in");
ofstream out("text.out");
int main() {
char text[10000];
in.get(text, 10000);
int cuvinte = 0, nr_cuvinte = 0;
for (int i = 0; i <= strlen(text); i++) {
if ((text[i] == '-' || text[i] == ' ' || text[i] == ',' || text[i] == '.' || text[i] == '?' || text[i] == '!') &&
(text[i + 1] >= 'a' && text[i + 1] <= 'z') || (text[i + 1] >= 'A' && text[i + 1] <='Z'))
cuvinte++;
if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <='Z'))
nr_cuvinte++;
}
out << nr_cuvinte/cuvinte;
return 0;
}