Pagini recente » Cod sursa (job #1603720) | Cod sursa (job #1000315) | Cod sursa (job #235423) | Cod sursa (job #2748608) | Cod sursa (job #2773709)
#include <fstream>
using namespace std;
/**********************************/
/// INPUT / OUTPUT
ifstream f("text.in");
ofstream g("text.out");
/**********************************/
/// GLOBAL DECLARATIONS
int ans, wordCount, letterCount;
char ch, prev_ch;
/**********************************/
/// FUNCTIONS
void Solution();
void Output();
/**********************************/
///-----------------------------------------
bool IsInAlphabet(char ch)
{
return ('a' <= ch && ch <= 'z') ||
('A' <= ch && ch <= 'Z');
}
///-----------------------------------------
inline void Solution()
{
f.get(prev_ch);
if (IsInAlphabet(prev_ch))
{
wordCount ++;
letterCount += 1;
}
while (f.get(ch))
{
if (!IsInAlphabet(ch))
{
if (IsInAlphabet(prev_ch))
wordCount ++;
}
else
{
letterCount ++;
}
prev_ch = ch;
}
}
///-----------------------------------------
inline void Output()
{
g << letterCount / wordCount;
}
///-----------------------------------------
int main()
{
Solution();
Output();
return 0;
}