Pagini recente » Cod sursa (job #758198) | Cod sursa (job #2272120) | Cod sursa (job #2600798) | Cod sursa (job #1793239) | Cod sursa (job #53772)
Cod sursa(job #53772)
#include<iostream.h>
#include <fstream.h>
#include <string.h>
fstream in ("text.in",ios::in);
fstream out ("text.out", ios::out); //Lasa-ma, te rog!
long s=0,n=0;
int did=0;
char word[1000000];
int let (char a)
{
if ( ('a' <= a && a <= 'z') || ('A' <= a && a <= 'Z') )
return 1;
return 0;
}
void count ()
{
did=1;
long sl,i,ew=1;
sl = strlen (word);
for (i=0;i<sl;i++)
{
// cout<<word[i]<<' '<<endl;
if (let (word[i]))
if (ew)
{
++n;
//sw = 1;
ew = 0;
++s;
// cout<<"ew="<<ew<<' '<<"sw="<<sw<<' '<<"s="<<s<<' '<<"n="<<n<<endl; getch();
}
else
{
++s;
// cout<<"ew="<<ew<<' '<<"sw="<<sw<<' '<<"s="<<s<<' '<<"n="<<n<<endl; getch();
}
else
if (!let (word[i]))
//if (sw)
{
//sw = 0;
ew = 1;
// cout<<"ew="<<ew<<' '<<"sw="<<sw<<' '<<"s="<<s<<' '<<"n="<<n<<endl; getch();
}
}
}
int main ()
{
// clrscr();
while (!in.eof())
{
in>>word;
count ();
//cout<<word<<' ';
}
if (did==0)
out<<"0";
// cout<<"Ceea ce cautai:"<<s/n;
out<<s/n;
// getch();
return 0;
}