어떠한 문제를 해결하기 위해 정해진, 명확하게 정의되고 순서가 있는 유한 개의 규칙으로 이루어진 집합.
말이 어려우니, 문제풀이 과정이라고 이해해야겠다.
예시 코드
public class Max3 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("세 정수의 최댓값을 구합니다.");
System.out.print("a의 값: ");
int a = stdIn.nextInt();
System.out.print("b의 값: ");
int b = stdIn.nextInt();
System.out.print("c의 값: ");
int c = stdIn.nextInt();
int max = a;
if (b > max) max = b;
if (c > max) max = c;
System.out.println("최댓값은 "+max+" 입니다.");
}
}
위 코드는 세 정수의 최댓값을 구하는 프로그램이다.
알고리즘 순서도(flowchart)는 아래와 같다.