Ocurrencia de Una Letra En un Texto [Codigo en C++]

Este programa consiste mostrar las letras (en mayusculas ) que ocurren pero en numeros referenciales de un texto

Por Ejemplo :

  • INGRESAMOS :  HOLA MARCO
MOTRARA  :
  1. A   =  1
  2. C   =  3
  3. H   =  8
  4. L   =  12
  5. M  =  13
  6. O  =  15
  7. R  =  18

 

#include <string.h>
#include <iostream>

using namespace std;

int main ()
{
system("color 9F");
char texto[100];
int i=0,j=65,cont=1;

cout<<"\n\n\n\n\t\t INGRESE TEXTO\n\n\n\t\t ";
gets(texto);

while (j<91){

while (i<strlen(texto)){

if(j==texto[i]){
cout<<"\n\n\t\t "<<cont++
<<".\t"<<texto[i]<<" : "
<<j-64;
break;
}
i++;
}

j++;
i=0;
}

cout<<"\n\n\n\t\t ";
system("PAUSE");
return 0;
}
Siguiente
« Post Anterior