Forum > Beginners

FreePascal: find all 3-symbol unique substring in string

(1/4) > >>

Program: find all 3-symbol unique substring in string.
I made program on PascalABC. Teacher want FreePascal.
This progran not work in FreePascal. Can you help me with FreePascal.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Program Zadanie2;type Mnoj=Set Of string[3];     var S: string;    i: integer;    Mn3: Mnoj;begin write('String: '); readln(S); for i:=1 to length(S)-2 do    Include(Mn3,S[i]+S[i+1]+S[i+2]);    i:=0; writeln('Substring: '); foreach S in Mn3 do  begin   Write(S,' ');   i:=i+1;  end; writeln; writeln('Sum=',i);end.

If you compile your code using fpc, it will tell you, line by line, what it does not like with your code. Looks to me that PascalABC has added a few extras that will almost certainly not be implemented in FP.

Are you sure your code works OK under PascalABC ?  In particular, the 'unique' requirement ? Looks to me like you capture every three letter combo, even if its already in your set.  But honestly, I have never heard of PascalABC until your message ....


In PascalABC.NET program correctly work - all subsring unique.
FPC-compiler writen "Illegal type declaration of set elements" in "type Mnoj=Set Of string[3]; "

type Mnoj=Set Of string[3];
type Mnoj=Array Of string[3];

You can use the PosEx  function to search for a substring in a string from a defines starting point.
Loop through the input string from begin to end.

using "Set Of" in this program - impossible in FCP ?


[0] Message Index

[#] Next page

Go to full version