Cod sursa(job #1574259)

Utilizator TheStifmeisterRusu Alex TheStifmeister Data 20 ianuarie 2016 13:55:04
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
using namespace std;
FILE *f, *g;
int l=0,w=0;
char s[10000000];

bool gaseste(char c)
{
    if (((c>='A') && (c<='Z')) || ((c>='a') && (c<='z')))
        return true;
    else return false;
}

int main()
{

    f = fopen("text.in", "r");
    g = fopen("text.out", "w");

    fscanf(f, "%s", &s);

    while (!feof(f))
    {
        for (int i = 0; s[i] != NULL; i++)
         {
             if (gaseste(s[i])==true)
                {
                    l++;
                    if ((gaseste(s[i-1])!=true) || (i==0)) w++;
                }
         }
         fscanf(f, "%s", &s);
    }


    fprintf(g, "%d", l/w);

    fclose(f);
    fclose(g);
    return 0;
}