Pagini recente » Cod sursa (job #333691) | Cod sursa (job #701710)
Cod sursa(job #701710)
#include <cstdio>
using namespace std;
const int MAXTEXT = 1100000;
char c;
int nr_cuvinte,l_cuvinte;
void citire()
{
freopen("text.in","r",stdin);
freopen("text.out","w",stdout);
}
void prelucrare()
{
bool cuvant = false;
while (scanf("%c",&c) != EOF)
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
{
++l_cuvinte;
cuvant = true;
}
else if (cuvant)
{
++nr_cuvinte;
cuvant = false;
}
if (cuvant)
++nr_cuvinte;
}
int main()
{
citire();
prelucrare();
printf ("%d",l_cuvinte / nr_cuvinte);
return 0;
}
/*
#include <cstdio>
using namespace std;
const int MAXTEXT = 1100000;
char text[MAXTEXT];
int nr_cuvinte,l_cuvinte;
void citire()
{
freopen("text.in","r",stdin);
freopen("text.out","w",stdout);
gets(text);
}
void prelucrare()
{
bool cuvant = false;
for (int i = 0;text[i] != 0;++i)
if((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
{
++l_cuvinte;
cuvant = true;
}
else if (cuvant)
{
++nr_cuvinte;
cuvant = false;
}
if (cuvant)
++nr_cuvinte;
}
int main()
{
citire();
prelucrare();
printf ("%d",l_cuvinte / nr_cuvinte);
return 0;
}
*/