Cod sursa(job #2515935)

Utilizator mafiotxrobeert mafiotx Data 29 decembrie 2019 20:18:23
Problema Text Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <istream>
using namespace std;

ifstream fin("text.in");
ofstream fout("text.out");

int main()
{
	string str;
	getline(fin, str);
	int pozI = -1;
	
	int i = 0;
	while (pozI == -1)
	{
		if (isalpha(str[i]))
			pozI = i;
			i++;
	}

	i = str.length();
	int pozF = -1;
	while (pozF == -1)
	{
		if (isalpha(str[i]))
			pozF = i;
		i--;
	}

	int charContor = 0;
	for (int i = pozI; i < pozF; i++)
		if (!isalpha(str[i]) && (isalpha(str[i - 1])))
			charContor++;

	int numarLitere = pozF - pozI - charContor + 1;
	int numarCuvinte = charContor + 1;

	f	out << numarLitere / numarCuvinte;

	system("pause>nul");
}