Pagini recente » Borderou de evaluare (job #521036) | Cod sursa (job #892906) | Cod sursa (job #2752143) | Cod sursa (job #1709530) | Cod sursa (job #2278605)
#include <fstream>
#include <string.h>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
int nr,nrc,i,n;
bool litera(char x){
if(x>='0' && x<'9')
return 1;
if(x>=65 && x<=90)
return 1;
if(x>=97 && x<=122)
return 1;
return 0;
}
int main()
{
char s[256];
while(f>>s){
n=strlen(s);
nr+=n;
nrc++;
if(n==1 && !litera(s[0])){
nr--;nrc--;}
if(!litera(s[n-1]) && n>1)
nr--;
for(i=0; i<n; i++)
if(!litera(s[i]) && i<(n-1) && i>0)
nr--,nrc++;
/*g<<s[i];
else
g<<" ";
g<<"\n";for(i=0; i<strlen(s); i++)
if(litera(s[i]))
g<<s[i]<<" ";*/
}
//g<<nrc<<" "<<nr;
g<<nr/nrc;
return 0;
}