Cod sursa(job #226173)

Utilizator raica_cristiraica dumitru cristian raica_cristi Data 1 decembrie 2008 08:33:04
Problema Text Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.95 kb
#include<fstream>
#include<string.h>

using namespace std;

ifstream fin ("text.in");
ofstream fout ("text.out");

char a[52]={'q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M'};
char sep[100]={'!',',','.','/','?',':','@','1','2','3','4','5','6','7','8','9','0','[','{',']','}',';','!','@','#','$','%','^','&','*','(',')','-','_','=','+','|','`','~'};

int main ()
{
    char x[100000];
    int n,i,k,cuv=0,lit=0,cuv2=0,d,e;
    
     while(fin>>x)   
    { k=strlen(x);
    k-=1;
    cuv++;
    for(i=0;i<=k;i++)
     {d=e=0;
     if(i>=1)
           {           if(strchr(a,x[i-1])>0 && strchr(a,x[i])==0 && strchr(sep,x[i-1])==0 )
                    {  d=1;
                   // fout<<x<<" "<<x[i-1];
                      if(strchr(a,x[i+1])>0 && strchr(a,x[i])==0 && strchr(sep,x[i+1])==0)
                      {e=1;
                    //  fout<<" "<<x[i+1]<<"\n";
                    }}}
                      if(e==1 && d==1)
                      cuv++;
                     if(strchr(a,x[i])==0)
                  n=0;
                  else
                  {                
                                    n=1;
                                    lit++;
                                    }}
    
                     }
  
  /*  fin.getline(x,85000);
    n=i=k=0;
    k=strlen(x);
    for(i=0;i<=k;i++)
    {
                     if(strchr(a,x[i])==0)
                  n=0;
                  else
                  {                 if(n==0)
                                    cuv++;
                                    n=1;
                                    lit++;
                                    }
                                       
                  }*/
    
                  fout<<(lit)/(cuv);
                  return 0;
                  }