본문 바로가기

프로그래밍

[프로그래밍, 자료구조] 큐(Queue) 큐는 FIFO(First In First Out) 형태의 자료구조로 먼저 들어간 데이터가 먼저 빠져나가는 것이다. 실생활에서 이와 비슷한 내용은 버스 줄서기로 먼저 줄을 선 사람이 먼저 버스를 탄다.이를 구현하는 방법은 여러가지 방법이 있는데, 여기서는 데이터 구조를 원형처럼 생각해서 구현하는 방법을 이용하였다. 디버그의 편의성을 위해서 총 4개의 파일로 분할해서 만들었다. 첫 번째는 배열의 크기가 0이면 에러를 발생시키게 하는 파일 소스이다. public class EQException extends Exception{ public EQException(){ super("The queue is empty!"); } } 두 번째는 interface로 Queue에 필요한 메서드를 선언하는 파일 소스이다. ..
[기능] 프로그램 실행시간 체크 아래와 같은 소스 코드를 이용하면 된다. #include #include int main(void){ LARGE_INTEGER liCounter1, liCounter2, liFrequency; QueryPerformanceFrequency(&liFrequency); QueryPerformanceCounter(&liCounter1); // 실행코드 입력 QueryPerformanceCounter(&liCounter2); printf("\n"); printf("Time: %f\n", (double)(liCounter2.QuadPart-liCounter1.QuadPart)/(double)liFrequency.QuadPart); }
[출력-자가진단8] 출력 - 자가진단8 Time Limit : 1000MS 다음과 같이 출력되는 프로그램을 작성하라. (각 요소들은 10칸씩 공간을 확보하여 오른쪽으로 정렬하여 출력한다.) #include int main(void){ printf("%10s%10s%10s\n","item","count","price"); printf("%10s%10d%10d\n", "pen", 20, 100); printf("%10s%10d%10d\n", "note", 5, 95); printf("%10s%10d%10d\n", "eraser", 110, 97); return 0;}
[출력-자가진단7] 출력 - 자가진단7 Time Limit : 1000MS 다음과 같이 출력되는 프로그램을 작성하라. (공백으로 구분하여 출력) 5단 5 * 2 = 10 #include int main(void){ printf("5단 \n5 * 2 = 10"); return 0;}
[출력-자가진단6] 출력 - 자가진단6 Time Limit : 1000MS 다음과 같이 출력되는 프로그램을 작성하라. 나의 키는 170 나의 몸무게 68.600000 #include int main(void){ int height = 170; double weight = 68.6; printf("나의 키는\n%d\n나의 몸무게\n%lf", height, weight); return 0;}
[출력-자가진단5] 출력 - 자가진단5 Time Limit : 1000MS 서식 문자를 사용하여 다음과 같이 출력되는 프로그램을 작성하라. 나도 프로그램을 잘할 수 있다. 꿈은 이루어진다. #include int main(void){ char str[100]="나도 프로그램을 잘할 수 있다.\n꿈은 이루어진다."; printf("%s", str); return 0;}
[출력-자가진단4] 출력 - 자가진단4 Time Limit : 1000MS 다음과 같이 출력되는 프로그램을 작성하라. #include int main(void){ printf("@@@@@\n@ @\n@@@@@\n@ @\n@@@@@"); return 0;}
[출력-자가진단3] 출력 - 자가진단3 Time Limit : 1000MS 나의 이름은 OOO입니다. 나의 나이는 OO살입니다.소스를 제출할 때 이름은 "홍길동", 나이는 "13"으로 하세요.. 나의 이름은 홍길동입니다. 나의 나이는 13살입니다. #include int main(void){ char name[10] = "홍길동"; int age = 13; printf("나의 이름은 %s입니다.\n나의 나이는 %d살입니다.", name, age); return 0;}