Pagini recente » Cod sursa (job #1743257) | Cod sursa (job #1121136) | Cod sursa (job #816953) | Cod sursa (job #186902) | Cod sursa (job #53760)
Cod sursa(job #53760)
#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!
int s=0,n=0;
char word[1000000];
int let (char a)
{
if ( ('a' <= a && a <= 'z') || ('A' <= a && a <= 'Z') )
return 1;
return 0;
}
void count ()
{
int 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<<' ';
}
// cout<<"Ceea ce cautai:"<<s/n;
out<<s/n;
// getch();
return 0;
}