Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE analyzechar;
- FROM InOut IMPORT WriteString, WriteLn, Read, Write;
- TYPE
- letters = SET OF ['A'..'z'];
- digits = SET OF ['0'..'9'];
- VAR
- allvowels, allconsonants: letters;
- alldigits : digits;
- ch : CHAR;
- CONST
- empty = letters{};
- wovels = letters{'A', 'E', 'I', 'O', 'U'};
- consonants = letters{'A'..'Z'} - wovels;
- dig = digits{'0'..'9'};
- BEGIN
- allvowels := empty;
- allconsonants := empty;
- alldigits := digits{};
- WriteString('Enter the text block that you want to analyze');
- WriteLn; WriteString('Finish your entering with a dot!');
- WriteLn;
- Read(ch);
- WHILE ch <> '.' DO
- (*everything is written correctly*)
- (*but function CAP in some versions of the module2*)
- (*from some reason doesn't work corectly!*)
- IF CAP(ch) IN wovels THEN
- INCL(allvowels,ch)
- END;
- IF CAP(ch) IN consonants THEN
- INCL(allconsonants,ch)
- END;
- IF ch IN dig THEN
- INCL(alldigits,ch)
- END;
- Read(ch);
- END;
- WriteLn;
- WriteString('All the vowels, which are found in the text, are: ');
- WriteLn;
- FOR ch := 'A' TO 'Z' DO
- IF ch IN allvowels THEN
- Write(ch);
- WriteString(' ');
- END
- END;
- WriteLn;
- WriteString('All the consonants, which are found in the text, are: ');
- WriteLn;
- FOR ch := 'A' TO 'Z' DO
- IF ch IN allconsonants THEN
- Write(ch);
- WriteString(' ');
- END
- END;
- WriteLn;
- WriteString('All the numbers which have been found in the text, are: ');
- WriteLn;
- FOR ch := '0' TO '9' DO
- IF ch IN alldigits THEN
- Write(ch);
- WriteString(' ');
- END
- END;
- END analyzechar.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement