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