M
M
Maxim2018-12-23 13:29:25
Pascal
Maxim, 2018-12-23 13:29:25

How to print all parts of a word starting with a given character in Turbo Pascal language?

I can't come up with an algorithm that will output parts of this word from a word that begin with an arbitrary entered character. For example: the word "Evanescent", when entered "E" should output: Evanescent escent ent Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-12-23
@maxpointn2point

The question is closed

var
    str,let,tmp:string;
    i,k,j:integer;
    x:array[1..50] of integer;

    begin
    readln(str);
    readln(let);
    tmp:=str;
    j:=1;
    while pos(let,tmp) > 0 do begin
        x[j]:=pos(let,tmp);
        tmp[pos(let,tmp)]:='0';
        inc(j);
    end;
    for i:=1 to j-1 do begin
       for k:=x[i] to length(str) do begin
           write(str[k]);
       end;
    writeln;
    end;
    end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question