Pagini recente » Cod sursa (job #3183948) | Cod sursa (job #2761895) | Cod sursa (job #536122) | Cod sursa (job #1116270) | Cod sursa (job #793794)
Cod sursa(job #793794)
#include<fstream>
#include<string>
using namespace std;
ifstream f("test.in");
ofstream o("test.out");
string mes;
char c;
int main()
{
getline(f,mes);
int words=1,totlength=0,i=0;
while(!((mes[i]>='A'&&mes[i]<='Z')||(mes[i]>='a'&&mes[i]<='z')))
{i++;}
for(;i<mes.length();i++)
{
if(mes[i]==' '||mes[i]=='-')
words++;
else
if((mes[i]>='A'&&mes[i]<='Z')||(mes[i]>='a'&&mes[i]<='z'))
totlength++;
}
o<<totlength/words;
return 0;
}