내 과제는 200 자의 알파 문자 배열을 허용하는 모듈을 의사 코드로 작성하는 것입니다. 200자를 무작위로 선택하고 배열에 넣는 코드는 어떻게 작성합니까?의사 코드의 무작위 문자
내 전체 과제는 다음과 같습니다
이 문자의 200 요소 배열을 받아 의사의 모듈을 만들고, 배열에있는 5 개 개의 모음 각각의 발생 횟수 (A를 결정, e, i, o, u)이고, 은 각 모음 의 발생 수를 화면에 인쇄합니다. [25 점]를
나는이 퍼팅의 쉬운 방법이 있는지 모르지만, 이것이 내가 알아 낸 것입니다 :
Module vowels(characterArray)
Declare Boolean found
Declare Integer Index
Declare Integer vowelA
Declare Integer vowelE
Declare Integer vowelI
Declare Integer vowelO
Declare Integer vowelU
Set found = false
Set index = 0
Set vowelA = 0
Set vowelE = 0
Set vowelI = 0
Set vowelO = 0
Set vowelU = 0
While found == false AND index <= size – 1
If characterArray[index] == ucase$(“a”)
Set vowelA = vowelA + 1
If characterArray[index] == ucase$(“e”)
Set vowelE = vowelE + 1
If characterArray[index] == ucase$(“i”)
Set vowelI = vowelI + 1
If characterArray[index] == ucase$(“o”)
Set vowelO = vowelO + 1
If characterArray[index] == ucase$(“u”)
Set vowelU = vowelU + 1
Else
Set found = true
Endif
Endif
Endif
Endif
Endif
Endwhile
Display “Number of A’s: “ ,vowelA
Display “Number of E’s: “ ,vowelE
Display “Number of I’s: “ ,vowelI
Display “Number of O’s: “ ,vowelO
Display “Number of U’s: “ ,vowelU
End Module
당신이 배열을 수락하거나 그 배열을 생성하는 모듈을 작성해야합니까? –
할당은 입력을 받아들이 기 위해 배열 생성을 요구하지 않습니다. –
알파벳 문자 26 개를 가진 배열을 만들고 싶었지만 무작위로 배열하는 방법을 알지 못했습니다. 배열을 받아들입니다. – Tara