Pagini recente » Cod sursa (job #1597259) | Cod sursa (job #1716010) | Cod sursa (job #2469445) | Cod sursa (job #122542) | Cod sursa (job #1728982)
#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();
}