의사코드 작성법
1. Start by writing down the purpose of the process.
의사코드가 무엇을 하려는 지 적어준다.
2. Write only one statement per line.
3. IF,ELSE,WHILE 같은 실행식은 대문자로 써야 구분돼 보여진다.
ex)
IF grade is grater than or equal to 60
Print "passed"
ELSE
Print "failed"
4. 요약하지 말고, 코딩을 모르는 사람이 봐도 알 수 있게 작성해야 한다.
ex)
IF input is odd, output "y" (x)
IF user enters ad odd
number, display "y" (o)
5. Pseudocode statements are close to simple English statements
Pseudocode does not typically use variables, but instead describes what the program should do with close-to-real-world objects such as account numbers, names, or transaction amounts.
ex)
IF n1 > n2
PRINT "n1"
IF n1 < n2
PRINT "n2" (x)
IF n1 is greater than n2
PRINT "n1 is greater"
ELSE n2 is greater than n1
PRINT "n2 is greater" (o)
6. Use standard programming structures
만들어내지 말고, 기존 프로그래밍 문법에 있는 거랑 같은 문법을 활용할 것
ex) for, do-while, if, function NAME (), {} 등
7. 짜여진 의사코드 예시
This program will request a greeting from the user. If the greeting matches a specific response, the response will be delivered; if not, a rejection will be delivered.
print greeting
"Hello stranger!"
print prompt
press "Enter" to continue
<user presses "Enter">
print call-to-action
"How are you today?"
display possible responses
"1. Fine."
"2. Great!"
"3. Not good."
print request for input
"Enter the number that best describes you:"
if "1"
print response
"Dandy!"
if "2"
print response
"Fantastic!"
if "3"
print response
"Lighten up, buttercup!"
if input isn't recognized
print response
"You don't follow instructions very well, do you?"
참고사이트 :
https://www.wikihow.com/Write-Pseudocode
https://ko.wikihow.com/%EC%9D%98%EC%82%AC%EC%BD%94%EB%93%9C-%EC%9E%91%EC%84%B1%EB%B2%95
'정리하기 이전 자료 ( before 20-11 ) > Algorithm' 카테고리의 다른 글
FloydWarshall 알고리즘 (0) | 2020.05.18 |
---|---|
동적 프로그래밍(Dynamic Programming) (0) | 2020.05.09 |
Stack and Queue (0) | 2020.05.08 |
Kruskal algorithm (0) | 2020.04.24 |
순서도 그리는 법 (0) | 2020.03.17 |
댓글