이클립스 내장 콘솔의 행동이 이상합니다.
글쓴이: noblepylon / 작성시간: 토, 2008/05/24 - 9:45오전
다음과 같은 코드를 이클립스에서 작성한 뒤 컴파일했습니다.
#include < cstdio > using namespace std; int main() { int i, j, n; /*n : this program will print all the prime numbers between 1 and n. */ printf("Give me an integer: "); scanf("%d", &n); // get the value of n. for(i = 2; i <= n; i++) { // i represent all the integers between 2 and n. for(j = 2; j < i; j++) { // This routine will check whether i is a prime number. // Simply, it tries to divide i by all possible integers. if(i % j == 0) { break; } } if(j == i) { // If the above routine finished without any halt, i is a prime number. // So, print i. printf("%d, ", i); } } printf("\n"); return 0; }
원래라면 "Give me an integer: "를 먼저 출력시킨뒤 정수입력을 받아야 합니다.
그런데 이클립스 내장 콘솔에서 이것을 실행시켜보면 아무 메시지를 출력하지를 않습니다.
숫자를 하나 입력해주어야만 메세지를 출력하더군요.
그래서 결국은 이런 결과가 나옵니다:
100 // 입력 Give me an integer: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, // 출력
"Give me an integer: "를 먼저 출력한 뒤에 입력을 받게 하려면 어떻게 해야 하나요?
ps. 외부에서 따로 실행을 시키면 원하는 동작이 나옵니다만, 매번 일일이 실행시키기가 상당히 귀찮군요.
Forums:
댓글 달기