Cod sursa(job #1728982)

Utilizator kcorflorinVoiculescu Florin kcorflorin Data 13 iulie 2016 22:55:04
Problema Text Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.05 kb
#include <iostream>
#include <string.h>
#include <fstream>
#include <stdlib.h>
#include <math.h>
char text_chars[9000];
int i,j,letters_count[100],word_counts=1,letters_count_total,math;
using namespace std;

void text_prog()
{
     ifstream text;
    text.open("text.in");
    text >> std::noskipws;

    while(!text.eof())
    {
        text>>text_chars[i];
        i++;
    }
    for(i=0;i<=strlen(text_chars);i++)
    {
        if( text_chars[i]==' ' )
        {
            word_counts++;
            i++;
            j++;
        }
        if((text_chars[i]>64 && text_chars[i]<91)||(text_chars[i]>96 && text_chars[i]<123))
        {
            letters_count[j]++;
        }
    }
    text.close();
    for(j=1;j<=word_counts;j++)
    {
        letters_count_total=letters_count_total+letters_count[j];
    }
}
void out()
{
    ofstream text_out;
    text_out.open("text.out");
    math=floor(letters_count_total/word_counts);
    text_out<<math;
    text_out.close();
}
int main()
{
   text_prog();
   out();
}