모든 답은 아래 교재를 참조합니다. 

 

싸니까 믿으니까 인터파크도서

생년월일 - 출생지 - 출간도서 0종 판매수 0권 (주)익스터디 대표이사, 두목넷 사무자동화 부분 대표 강사로 IT 자격증 분야에서 '왕두목'이라는 애칭으로 활발히 활동하고 있습니다. 경기공업대

book.interpark.com

 

13. 다음은 C언어로 구현된 프로그램을 실행했을 때, <실행 결과>와 같이 출력되도록 빈 줄 (1) ~ (3) 에 들어갈 가장 적합한 C표현을 쓰시오. 

<실행결과>

1 2 4 7
#include <stdio.h>
#define SIZE 4

void bubble_sort(int* list)
{
    int i, j, temp;
    
    for(i = 0; i < SIZE-1; i++) {
        
        for(j = 0; j < (SIZE-1)-i; j++) {
            
            if(__1__ > list[j + 1]) {
                temp = list[j];
                list[j] = list[j+1];
                list[j+1] = temp;
            }
        }
    }
    
    for(i = 0; i < SIZE; i++)
        printf("%d ", __2__);
}

void main()
{
    int list[SIZE] = {7, 2, 4, 1};
    __3__(list);
}

[정답]

  • 답 (1) : list[j]
  • 답 (2): list[i]
  • 답 (3): bubble_sort

14. 다음은 피보나치 수열의 합을 구하도록 Java로 작성된 프로그램이다. 이를 실행한 결과를 쓰시오. 

public class Exam{

     public static void main(String []args){
        int a, b, c, sum;
        a = b = 1;
        sum = a + b;
        for(int i = 3; i <= 5; i++) {
            c = a + b;
            sum += c;
            a = b;
            b = c;
        }
        System.out.println(sum);
     }
}
------
12

모든 답은 아래 교재를 참조합니다. 

 

싸니까 믿으니까 인터파크도서

생년월일 - 출생지 - 출간도서 0종 판매수 0권 (주)익스터디 대표이사, 두목넷 사무자동화 부분 대표 강사로 IT 자격증 분야에서 '왕두목'이라는 애칭으로 활발히 활동하고 있습니다. 경기공업대

book.interpark.com

10. 다음은 C언어로 작성된 선택정렬의 오름차순을 수행하는 프로그램이다. 빈 칸 (1) ~ (2)에 알맞은 표현을 쓰시오. 

#include <stdio.h>

int main()
{
   int a[] = {95, 75, 85, 100, 50};
   int i, j, temp;
   int n = sizeof(a) / sizeof(int); // int n = 5;
   
   for(i = 0; i < n-1; i++) {
       for(j = i+1; j < n; j++) {
           if(a[i] > a[j]) {
               temp = a[i];
               a[i] = a[j];
               a[j] = temp;
           }
       }
   }
   
   for(i = 0; i < 5; i++) {
       printf("%d ", a[i]);
   }
   
   return 0;
}

--- 
50 75 85 95 100 

 

11. 다음은 Java로 작성된 프로그램이다. 이를 실행한 결과를 쓰시오. 

public class Exam {
    public static int[] makeArray(int n) {
        int[] t = new int[n];
        for(int i=0; i < n; i++){
            t[i] = i*2;
            System.out.printf("t[%d] = %d * 2 = %d\n", i, i, t[i]);
        }
        return t;
    }
    
    public static void main(String[] args) {
        int[] a = makeArray(5);
        for(int i = 0; i < a.length; i++) {
            System.out.printf("the number == %d\n", i);
            if(i%2 == 0) continue;
            System.out.printf("the number == a[%d] == %d\n", i, a[i]);
            // System.out.print(a[i] + " ");
        }
    }
}

----
t[0] = 0 * 2 = 0
t[1] = 1 * 2 = 2
t[2] = 2 * 2 = 4
t[3] = 3 * 2 = 6
t[4] = 4 * 2 = 8
the number == 0
the number == 1
the number == a[1] == 2
the number == 2
the number == 3
the number == a[3] == 6
the number == 4

12. 다음은 Java로 작성된 프로그램이다. 이를 실행한 결과를 쓰시오. 

public class Exam{

     public static void main(String []args){
        int a = 1, b = 43, c = 3;
        int temp;
        
        temp = a;
        if(b > temp) temp = b;
        if(c > temp) temp = c;
        
        System.out.println(temp);
     }
}

----
43

모든 답은 아래 교재를 참조합니다. 

 

싸니까 믿으니까 인터파크도서

생년월일 - 출생지 - 출간도서 0종 판매수 0권 (주)익스터디 대표이사, 두목넷 사무자동화 부분 대표 강사로 IT 자격증 분야에서 '왕두목'이라는 애칭으로 활발히 활동하고 있습니다. 경기공업대

book.interpark.com

 

1. 다음은 Java로 작성된 프로그램이다. 이를 실행한 결과를 쓰시오. 

class SuperObject {
    public void paint() {
        draw();
    }
    
    public void draw() {
        draw();
        System.out.println("Super Object");
    }
}

class SubObject extends SuperObject {
    public void paint() {
        super.draw();
    }
    
    public void draw() {
        System.out.println("Sub Object");
    }
}

public class Exam
{
    public static void main(String[] args) {
        SuperObject b = new SubObject();
        b.paint();
    }
}

답:

Sub Object

Super Object

 

2. 다음은 Java로 작성된 프로그램이다. 이를 실행한 결과를 쓰시오. 

public class Exam
{
	public static void main(String[] args) {
    	int n = 0;
        int num = 110;
        for(int i=1; i<=num; i++) {
        	if(i%4 == 0) n++;
        }
        
        System.out.println(n);
    }
}
---
27

 

모든 답은 아래 교재를 참조합니다. 

 

싸니까 믿으니까 인터파크도서

생년월일 - 출생지 - 출간도서 0종 판매수 0권 (주)익스터디 대표이사, 두목넷 사무자동화 부분 대표 강사로 IT 자격증 분야에서 '왕두목'이라는 애칭으로 활발히 활동하고 있습니다. 경기공업대

book.interpark.com

 

5. STUDENT 테이블에 독일어과 학생 50명, 중국어과 학생 30명, 영어영문학과 학생 50명의 정보가 저장되어 있을 때, 다음 두 SQL문의 실행 결과 튜플 수는? (단, DEPT 컬럼은 학과명)

SELECT DEPT FROM STUDENT;
SELECT DISTINCT DEPT FROM STUDENT;

정답:

-- 1) 130

-- 2) 3

16. 다음은 입력받은 자연수(N)의 각 자릿수의 합을 C언어로 작성한 프로그램이다. C 프로그램상의 빈 줄 (1) ~ (2)에 들어갈 적당한 C 표현을 쓰시오. 

(예: 123 입력 후, 결과 1 + 2+ 3 = 6)

<출력결과>

자연수 입력: 1234567
자릿수 합계: 28
#include <stdio.h>

void main()
{
    int input;
    int output = 0;
    printf("자연수 입력: ");
    scanf("%d", &input);
    while(input)
    {
        output += input % 10;
        printf("output: %d input: %d \n", output, input);
        input /= 10;
        printf("input: %d\n", input);
        printf("-----\n");
    }
    
    printf("자릿수 합계: %d\n", output);
}

---
자연수 입력: 1234567                                                                                                                   
output: 7 input: 1234567                                                                                                               
input: 123456                                                                                                                          
-----                                                                                                                                  
output: 13 input: 123456                                                                                                               
input: 12345                                                                                                                           
-----                                                                                                                                  
output: 18 input: 12345                                                                                                                
input: 1234                                                                                                                            
-----                                                                                                                                  
output: 22 input: 1234                                                                                                                 
input: 123                                                                                                                             
-----                                                                                                                                  
output: 25 input: 123                                                                                                                  
input: 12                                                                                                                              
-----                                                                                                                                  
output: 27 input: 12                                                                                                                   
input: 1                                                                                                                               
-----                                                                                                                                  
output: 28 input: 1                                                                                                                    
input: 0                                                                                                                               
-----                                                                                                                                  
자릿수 합계: 28

20. 다음은 자바 언어로 구현된 프로그램을 분석하여 그 실행 결과를 쓰시오. 

public class MyClass {
    public static void main(String args[]) {
      int [] a = new int[8];
      int n = 11;
      int i = a.length-1;
      
      while(n != 0)
      {
          a[i] = n%2;
          System.out.printf("i = %d, n = %d\n", i, n);
          n /= 2;
          System.out.printf("a[%d] = %d\n", i, a[i]);
          i--;
      }
      System.out.println("-----");
      for(int j = 0; j < a.length; j++)
        System.out.printf("a[%d] = %d\n", j, a[j]);
    }
}
----
i = 7, n = 11
a[7] = 1
i = 6, n = 5
a[6] = 1
i = 5, n = 2
a[5] = 0
i = 4, n = 1
a[4] = 1
-----
a[0] = 0
a[1] = 0
a[2] = 0
a[3] = 0
a[4] = 1
a[5] = 0
a[6] = 1
a[7] = 1

 

+ Recent posts