4 answers
Hello 5o5a,
https://fr.wiktionary.org/wiki/monovocalisme
You can define a type
Then, you can easily test if a letter in the word you are analyzing is a vowel or not, like this:
This is really the only practical tip to make your life easier; the rest is very basic and assumes that you know how to use booleans, make loops and tests, and iterate through the letters of a string.
Dal
https://fr.wiktionary.org/wiki/monovocalisme
You can define a type
set of char;and a variable
voyellesusing this type, which will allow you to include all the vowels of the alphabet you are working with.
Then, you can easily test if a letter in the word you are analyzing is a vowel or not, like this:
if mot[n] in voyelles thenby varying the variable
integerthat I called
n(you can name it whatever you want) from 1 to the number of letters in the word.
This is really the only practical tip to make your life easier; the rest is very basic and assumes that you know how to use booleans, make loops and tests, and iterate through the letters of a string.
Dal
Good evening
It can be done with a Regex
You then check that all occurrences are the same vowel.
We should even be able to find a Regex that does the job in one go, but I don't really have time to dig into that.
--
When I was little, the Dead Sea was only sick.
George Burns
It can be done with a Regex
[aeiouy]with the IgnoreCase option
http://regexstorm.net/tester?p=%5baeiouy%5d&i=In+this+moment%2c+indeed%2c+you+are+the+boss%2c+put+–+believe+me+–+this+time+is+short+and+I+prefer+to+be+in+my+shoes+than+in+your+troubles&o=i
You then check that all occurrences are the same vowel.
We should even be able to find a Regex that does the job in one go, but I don't really have time to dig into that.
--
When I was little, the Dead Sea was only sick.
George Burns
I tried to run this program but it didn't work:
program MonoEn_v;
uses wincrt;
Type
tab=array[1..20]of string;
Var
n:integer;t:tab;v:char;
procedure fill(n:integer;var t:tab);
Var i,j:integer;
Begin
For i:=1 to n Do
Begin
Repeat
Write('give a string: ');readln(t[i]);
j:=0;
Repeat
j:=j+1;
Until not(upcase(t[i][j]) in ['A'..'Z']) or (j=length(t[i]));
until (upcase(t[I][j]) in ['A'..'Z']) and (length(t[i]) in [3..15]);
end;
end;
procedure enter_v(var v:char);
Begin
Repeat
writeln('give a character v');readln(v);
until (upcase(v) in ['A','E','I','O','U','Y']);
end;
procedure display(n:integer;t:tab;v:char);
Var i,j:integer; test:boolean;
Begin
test:=false;
writeln('the mono-vocalism words in "',v,'" are: ');
for i:=1 to n Do
Begin
for j:=1 to length(t[i]) do
Begin
Repeat
test:=true;
Until (t[i][j] <>v ) and (t[i][j] in ['A','E','I','O','U','Y']);
end;
writeln(t[i],'|');
end;
end;
begin
Repeat
Readln(n);
until n in [1..20];
fill(n,t);
enter_v(v);
display(n,t,v);
end.
program MonoEn_v;
uses wincrt;
Type
tab=array[1..20]of string;
Var
n:integer;t:tab;v:char;
procedure fill(n:integer;var t:tab);
Var i,j:integer;
Begin
For i:=1 to n Do
Begin
Repeat
Write('give a string: ');readln(t[i]);
j:=0;
Repeat
j:=j+1;
Until not(upcase(t[i][j]) in ['A'..'Z']) or (j=length(t[i]));
until (upcase(t[I][j]) in ['A'..'Z']) and (length(t[i]) in [3..15]);
end;
end;
procedure enter_v(var v:char);
Begin
Repeat
writeln('give a character v');readln(v);
until (upcase(v) in ['A','E','I','O','U','Y']);
end;
procedure display(n:integer;t:tab;v:char);
Var i,j:integer; test:boolean;
Begin
test:=false;
writeln('the mono-vocalism words in "',v,'" are: ');
for i:=1 to n Do
Begin
for j:=1 to length(t[i]) do
Begin
Repeat
test:=true;
Until (t[i][j] <>v ) and (t[i][j] in ['A','E','I','O','U','Y']);
end;
writeln(t[i],'|');
end;
end;
begin
Repeat
Readln(n);
until n in [1..20];
fill(n,t);
enter_v(v);
display(n,t,v);
end.
1.
To post your code on the forum, use the code tag; otherwise, your code is unreadable.
Like this:
<code delphi>
copy-paste your Pascal program code here
</code>
If you don't want to type the code tags yourself, you can click on the small arrow to the left of the forum's image icon and by choosing the "delphi" language, it will insert the tags into the message editing window for you, and you will only need to copy and paste your Pascal code between the two tags, as illustrated above.
This will number the lines of the program, provide Pascal syntax coloring, and preserve the indentation of your code, making it more readable for everyone.
2.
I quickly looked at your code anyway.
If I understand correctly, in your code, you are handling an array of strings, where each string contains several words, and you intend to check for each word if they are monovocalisms with respect to a certain vowel given by the user, and if so, to establish the list and indicate to the user which words they are.
You must therefore already have a way to distinguish the words from each other in the string (in a sentence, they are separated by spaces and punctuation marks).
For example, create a function or procedure that, from a string, returns the words contained in that string.
Next, to check if each word is a monovocalism with respect to a certain vowel provided by the user, create a function
Then, you can display the words that pass the test as you go, or if you need to keep them in memory, store them in some way using a data structure from the Pascal language.
3.
Which Pascal compiler are you using?
Dal
To post your code on the forum, use the code tag; otherwise, your code is unreadable.
Like this:
<code delphi>
copy-paste your Pascal program code here
</code>
If you don't want to type the code tags yourself, you can click on the small arrow to the left of the forum's image icon and by choosing the "delphi" language, it will insert the tags into the message editing window for you, and you will only need to copy and paste your Pascal code between the two tags, as illustrated above.
This will number the lines of the program, provide Pascal syntax coloring, and preserve the indentation of your code, making it more readable for everyone.
2.
I quickly looked at your code anyway.
If I understand correctly, in your code, you are handling an array of strings, where each string contains several words, and you intend to check for each word if they are monovocalisms with respect to a certain vowel given by the user, and if so, to establish the list and indicate to the user which words they are.
You must therefore already have a way to distinguish the words from each other in the string (in a sentence, they are separated by spaces and punctuation marks).
For example, create a function or procedure that, from a string, returns the words contained in that string.
Next, to check if each word is a monovocalism with respect to a certain vowel provided by the user, create a function
isMonovocalismethat returns a boolean and takes as parameters a string containing the word to check, and a char containing the vowel against which this verification should be made.
Then, you can display the words that pass the test as you go, or if you need to keep them in memory, store them in some way using a data structure from the Pascal language.
3.
Which Pascal compiler are you using?
Dal