Help in pseudocodigo

0

In a vector called LETTERS of dimension 20, allow the user to enter N characters Alphabetical ('a', ..., 'z'), then show each character of the vector and the frequency with which this character appears in the vector. Example: Suppose that the user enters the following alphabetic characters in the LETTER vector LETTERS D E A P R E Y T D K E T D P E Then, the solution that you write for the problem should, after capturing the characters in The vector produce the following report: D Appears 3 times in the LETTER vector E Appears 4 times in the vector LETTERS A Appears 1 time in the vector LETTERS P Appears 2 times in the LETTER vector R Appears 1 time in the vector LETTERS Y Appears 1 time in the vector LETTERS T Appears 2 times in the vector LETTERS K appears 1 time in the vector LETTERS

The only thing I've done is add an accountant, I'm doing it in pseint before passing it to c #

Escribir "digite una palabra";
leer palabra;

Para i<-1 Hasta 20 Con Paso 1 Hacer
    LETRAS[i] <- palabra;
Fin Para

Para i<-1 Hasta 20 con Paso 1 Hacer
    Si LETRAS[I]== "A" || LETRAS[I] == "a" Entonces
        a <- a + 1;
    Fin Si
Fin Para

where "word" is a character and LETTERS is a vector

    
asked by deiby steven peralta 07.09.2017 в 04:51
source

3 answers

1
Escribir "digite una palabra";
leer palabra;
//Lo hago asi porque no recuerdo como se hace en psint
declarar un char ='';
declarar un contador=0;

Para i<-1 Hasta 20 Con Paso 1 Hacer
    Para k<-1 Hasta 20 con Paso 1 Hacer
      caracter = palabra[i]
      si caracter == palabra[y]
         contador++
      Fin Si
      Imprimir el caracter(variable caracter) aparece contador veces
      contador=0
    Fin Para
Fin Para

What he does in the first cycle is to take the first letter of the arrangement, then in the second cycle he compares the rest of the arrangement, if there are more equal letters, add the character, after obtaining the first letter he passes to the second iteration of the first for, then and do the above to read the last character.

I leave you a functional example in C #, it is a simple windows form that contains a button, a textbox where you enter the string and a listbox to show results. When you click on the button it takes the text that is in the textbox1 and shows the results in the listbox.

 private void button1_Click(object sender, EventArgs e)
        {

            string line = textBox1.Text;
            char caracter = ' ';
            int compt = 0;


            string checkd = "";

            for (int x = 0; x < line.Length; x++)
            {
                if (!checkd.Contains(line[x].ToString())) //Revisa si la letra ya ha sido contada
                {
                    for (int y = 0; y < line.Length; y++)
                    {
                        caracter = line[x];
                        if (caracter == line[y])
                        {
                            compt++;
                        }
                    }
                    listBox1.Items.Add("El caracter " + caracter + " aparece" + compt + " veces");
                    compt = 0;

                    checkd += line[x].ToString(); // Almacena la letra contada
                }
            }
        }

Here is an illustrative image.

If you notice the blank spaces also, I hope you serve, greetings.

    
answered by 07.09.2017 в 07:23
0

PSeInt can not recognize a character string as an array, because in PSeInt string it is just a data type, therefore this code can not execute it.

    
answered by 19.09.2017 в 13:53
0

I've been exploring PSEInt a bit, and I think it's a very interesting environment to start with programming.

The algorithm that you ask would be as shown below, in PSEInt pseudocode (the indexes of the vectors are based on 1).

Algoritmo FrecuenciasCaracteres
    Dimension LETRAS[20];
    Dimension FREC[20];
    Definir N como Entero;
    Definir c Como Caracter;

    // Pedir los N caracteres al usuario
    N <- 5;
    para i<- N hasta 1 Hacer
        Escribir "Introduzca una letra (quedan ", i, "): ";
        Leer c;
        LETRAS[(N - i) + 1] <- c;
    FinPara

    // Calcular las frecuencias
    para i<-1 hasta N Hacer
        FREC[i] <- 0;
        para j<-1 hasta N Hacer
            si LETRAS[j] = LETRAS[i] Entonces
                FREC[i] = FREC[i] + 1;
            FinSi
        FinPara
    FinPara

    // Visualizar los datos
    para i<-1 hasta N Hacer
        Escribir "Letra #", i, " ", LETRAS[i], " aparece: ", FREC[i], " veces.";
    FinPara
FinAlgoritmo

The user could also be asked for N. I hope it helps you.

    
answered by 20.09.2017 в 09:42