Pagini recente » Cod sursa (job #2842100) | Cod sursa (job #178003) | Cod sursa (job #2612554) | Cod sursa (job #1597149) | Cod sursa (job #1250827)
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main(){
std::string text;
int count_cuv = 0, count_litere = 0;
std::ifstream input("text.in");
getline(input, text);
for (unsigned int i = 0; i < text.length(); i++){
if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
count_litere++;
else{
if (i >= 1 && i <= text.length()){
if (((text[i - 1] >= 'a' && text[i - 1] <= 'z') || (text[i - 1] >= 'A' && text[i - 1] <= 'Z')))
{
count_cuv++;
}
}
}
}
if ((text[text.length()-1] >= 'a' && text[text.length()-1] <= 'z') || (text[text.length()-1] >= 'A' && text[text.length()-1] <= 'Z'))
count_cuv++;
std::ofstream output("text.out");
if (count_cuv != 0){
output << count_litere / count_cuv;
}
else{
output << count_litere;
}
return 0;
}