#include <iostream>
#include <cctype>
#include <cstring>
//Program to analyze paragraphs (It does not count the numbers) in order to work correctly you have to after a dot, comma, or semicolon, type space.
using namespace std;
int main(){
char array[1000];
int i = 0;
int num_p = 0;
cout<< "Enter a paragraph: ";
gets(array);
int s = 0;
int ch = 97;
int pal1 = 0;
int pal2 = 0;
int ora = 0;
//Programa letras
for(ch = 97;ch < 123; ch ++){// contador para minusculas ( int a = 97 ... int z = 123)
for(i = 0; i < strlen(array); i ++){
if (int (array[i]) == ch){
s = s + 1;
}
}
pal1 = s + pal1;
cout<<"Hay " << s << " "<< char(ch) << "s" << " \n";
s = 0;
}
cout<< "\n ";
s = 0;
for(ch = 65;ch < 91; ch ++){ // contador para mayusculas ( int A = 65 ... int Z = 91)
for(i = 0; i < strlen(array); i ++){
if (int (array[i]) == ch){
s = s + 1;
}
}
pal2 = s + pal2;
cout<<"There are / is " << s << " "<< char(ch)<< "s" << " \n";
s = 0;
}
//Programa palabras
for(i=0; i < strlen(array) ;i ++){ //Cuenta los espacios
if (array[i] == ' '){
num_p = 1 + num_p;
}
}
//Programa oraciones
for(i = 0; i < strlen(array); i ++ ){
if (array[i+1] == ' '){ // esto analiza si hay un espacio despues de la coma(punto etc..)
if (int(array[i]) == 44){ // esto es para indentificar si son , o . o ; que separan oraciones
ora = ora + 1;
}
else if (int(array[i]) == 46 ){
ora = ora + 1;
}
else if (int(array[i]) == 59 ){
ora = ora + 1;
}
}
}
cout << "# Letters: \n "<< pal1 + pal2 << "\n";
cout<< "# Words: " << num_p << "\n ";
cout << "# phrases: \n "<< ora << "\n";
return 0;
}
Again spanish ;).
Comments