How to resolve the algorithm Determine if a string has all unique characters step by step in the Ada programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Determine if a string has all unique characters step by step in the Ada programming language
Table of Contents
Problem Statement
Given a character string (which may be empty, or have a length of zero characters):
Use (at least) these five test values (strings):
Show all output here on this page.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Determine if a string has all unique characters step by step in the Ada programming language
Source code in the ada programming language
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_All_Chars_Unique is
procedure All_Chars_Unique (S : in String) is
begin
Put_Line ("Input = """ & S & """, length =" & S'Length'Image);
for I in S'First .. S'Last - 1 loop
for J in I + 1 .. S'Last loop
if S(I) = S(J) then
Put (" First duplicate at positions" & I'Image &
" and" & J'Image & ", character = '" & S(I) &
"', hex = ");
Put (Character'Pos (S(I)), Width => 0, Base => 16);
New_Line;
return;
end if;
end loop;
end loop;
Put_Line (" All characters are unique.");
end All_Chars_Unique;
begin
All_Chars_Unique ("");
All_Chars_Unique (".");
All_Chars_Unique ("abcABC");
All_Chars_Unique ("XYZ ZYX");
All_Chars_Unique ("1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ");
end Test_All_Chars_Unique;
You may also check:How to resolve the algorithm Tokenize a string step by step in the Java programming language
You may also check:How to resolve the algorithm Padovan n-step number sequences step by step in the C++ programming language
You may also check:How to resolve the algorithm Define a primitive data type step by step in the Visual FoxPro programming language
You may also check:How to resolve the algorithm Currency step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Evaluate binomial coefficients step by step in the 360 Assembly programming language