Pagini recente » Cod sursa (job #2903457) | Cod sursa (job #2698801) | Cod sursa (job #3203426) | Cod sursa (job #748343) | Cod sursa (job #167608)
Cod sursa(job #167608)
#include <fstream>
using namespace std;
int main ()
{
ifstream f ("text.in", ios::in);
ofstream g ("text.out", ios::out);
char text[10000];
f.getline (text, 10000);
int nrcuv=0, nrlit=0;
for (int i=0; text[i]!=NULL; i++)
{
if ( (text[i]>='A' && text[i]<='Z') || (text[i]>='a' && text[i]<='z') )
nrlit++;
if ( (text[i]==' ') && ( ( (text[i-1]>='A' && text[i-1]<='Z') || (text[i-1]>='a' && text[i-1]<='z') ) || ( (text[i-2]>='A' && text[i-2]<='Z') || (text[i-2]>='a' && text[i-2]<='z') ) ) )
nrcuv++;
if ( (text[i]=='-') && ( ( (text[i-1]>='A' && text[i-1]<='Z') || (text[i-1]>='a' && text[i-1]<='z') ) ) )
nrcuv++;
}
nrcuv++;
g<<nrlit/nrcuv;
return 0;
}