Pagini recente » Cod sursa (job #1725901) | Cod sursa (job #2389114) | Cod sursa (job #2354525) | Cod sursa (job #1130397) | Cod sursa (job #2211998)
#include <fstream>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
int main()
{
char ch;
int cnt=0,ok=0,lit=0;
while(fin>>ch)
{
// fout<<"spatiu "<<ok<<endl;
if(ch>='a' && ch<='z' || ch>='A' && ch<='Z')
{
ok++;
lit++;
}
else
{
if(ok>0)
{cnt++;
}
ok=0;
}
if (fin.peek() == ' ' )
{
if(ok>0)
{cnt++;
}
ok=0;
}
}
if(ch>='a' && ch<='z' || ch>='A' && ch<='Z')
cnt++;
if(cnt!=0)
fout<<lit/cnt;
else
fout<<0;
return 0;
}