Cod sursa(job #1170371)

Utilizator andreey_047Andrei Maxim andreey_047 Data 13 aprilie 2014 13:53:16
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <fstream>
#include <cstring>
#define Nmax 1000005
using namespace std;
char a[Nmax],ch,lch;
int n,num,numcuv;
int Litera(char ch){
  if((ch>='a' && ch<='z') || (ch>='A'&&ch<='Z'))
   return 1;
  return 0;
}
void Read(){
  ifstream fin("text.in");
  while(fin.get(ch)){
    if(Litera(ch))
     num++;
    else if(Litera(lch))
     numcuv++;
    lch=ch;
  }
  fin.close();
}
void Afisare(){
  ofstream fout("text.out");
  if(numcuv == 0) fout <<"0\n";
  else
  fout << num/numcuv<<"\n";
  fout.close();
}
int main(){
    Read();
    Afisare();
    return 0;
}