Pagini recente » Cod sursa (job #1900025) | Cod sursa (job #3227648) | Cod sursa (job #3211158) | Cod sursa (job #3185518) | Cod sursa (job #1524782)
#include <fstream>
#include <string>
#include <sstream>
#include <cctype>
typedef unsigned uint;
std::fstream in, out;
std::string text;
uint words, len;
inline void getWholeFile()
{
std::stringstream ss;
ss << in.rdbuf();
text = ss.str();
}
int main(int argv, char **argc)
{
in.open("text.in", std::fstream::in);
out.open("text.out", std::fstream::out);
getWholeFile();
for (int i = text.size() - 1; i > -1; --i)
if (std::isalpha(text[i]))
{
++len;
for (--i; i > -1; --i)
if (std::isalpha(text[i])) ++len;
else
{
++words;
break;
}
}
out << len / words;
return 0;
}