This repository was archived by the owner on May 18, 2024. It is now read-only.
forked from its-anaehm/CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCadenas.cpp
More file actions
59 lines (49 loc) · 1.63 KB
/
Cadenas.cpp
File metadata and controls
59 lines (49 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
@author its_anaehm
@date 10-08-2020
@version 0.1
*/
/*
Programa en C++ que lea un parrafo desde el teclado y lo imprima con las siguientes modificaciones:
1) Las letras iniciales y finales de cada palabra den ser impresas en minúscula
2) Las letras intermedias de cada palabra deben ser impresas en mayuscula
3) Si una palabra contiene solo un caracter entonces se va a imprimir sin modificación
4) Los caracteres que no forman parte del abecedario se van a imprimir sin modificación.
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <ctype.h>
using namespace std;
void primeraLetra(string);
int main() {
string texto;
cout<<"Introduzca un parrafo: "<<endl;
getline(cin, texto);
primeraLetra(texto);
return 0;
}
void primeraLetra(string texto){
int a=0;
int relleno;
a = texto.length();
for(relleno=0; texto[relleno]!='\0' ; relleno++) {
texto[0] = tolower(texto[0]);
if(texto[relleno] >= 'a' && texto[relleno] <= 'z'){
texto[relleno] = toupper(texto[relleno]);
}
if(texto[relleno-1]==' ' || texto[relleno-1]=='\n') {
texto[relleno] = tolower(texto[relleno]);
}
if(texto[relleno-1]==' ' || texto[relleno-1]=='\n') {
texto[relleno-2] = tolower(texto[relleno-2]);
}
texto[a-1] = tolower(texto[a-1]);
}
cout<<"\n*************************************************************"<<endl;
cout<<"\nTexto Modificado:\n"<<endl;
cout<<"*************************************************************\n"<<endl;
cout<<texto<<endl;
}