Cod sursa(job #791918)

Utilizator asem_kosteaFrunza Constantin asem_kostea Data 25 septembrie 2012 19:25:54
Problema Text Scor 70
Compilator cpp Status done
Runda asem-etapa1 Marime 0.96 kb
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <string.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	
 ifstream fin("text.in");
 ofstream fout("text.out");
 char *cuv=new char[1000];
  
 int lmax=0;
 int nrcuv=0;
 int t=0;
 while(fin>>cuv){
	t=0;
		for(int i=0;i<strlen(cuv);i++){		
 if((cuv[i]>='a'&&cuv[i]<='z')||(cuv[i]>='A'&&cuv[i]<='Z'))
 {
  lmax++;
 t=1; 
 } 
 
  if((i<strlen(cuv)-1) &&(cuv[i]=='-') && (cuv[i+1]!='-') && (strlen(cuv)>1)) nrcuv++;
}
if(t)
	nrcuv++;
	

}
//cout<<lmax<<" "<<nrcuv;
if(nrcuv!=0)
 fout<<lmax/nrcuv;
else fout<<0;
// do      
 //    {
		 
		 		
  //        fin>>cuv;
//cout<<cuv<<endl;   
	 
//	  }      while (!fin.eof( )) ;
     fin.close( );
 
  
 //for(int i=0;i<strlen(cuv);i++)
 //if(i!=strlen(cuv)-1)
 // if(cuv[i]==' ' &&cuv[i+1]!=' ') k++;
  
  //cout<<k;
	return 0;
}