Describe 새싹교실/2012/AClass/5회차 here =곽길문= 2.Swap함수 작성 --#include void swap(int *a,int *b); int main() { char x='A',y='B'; printf("x= %c y=%c\n",x,y); swap(&x,&y); printf("x=%c ,y=%c\n",x,y); return 0; } void swap(int *a,int *b) { int temp; temp=*a; *a=*b; *b=temp; } 3. 3,4,6,7,9,3,2를 입력으로 넣은 후 2,3,9,7,6,4,3순서로 출력하는 프로그램을 작성해보세요.(스택) #include #define MaxSize 7 int stack[MaxSize]; int sp=0; int push(int); int pop(int *); int main(){ int n=0; push(3); push(4); push(6); push(7); push(9); push(3); push(2); if (push(40) == -1) { printf("Stack Overflow\n"); } pop(&n); printf("pop : %d\n",n); pop(&n); printf("pop : %d\n",n); pop(&n); printf("pop : %d\n",n); pop(&n); printf("pop : %d\n",n); pop(&n); printf("pop : %d\n",n); pop(&n); printf("pop : %d\n",n); pop(&n); printf("pop : %d\n",n); if(pop(&n) == -1) { printf("Stack Underflow\n"); } return 0; } int push(int n) { if(sp0) //값튕�이I 있O을≫ 때納� { sp--; *n=stack[sp]; return 0; }else { return -1; //비촱었�을≫ 때納� underflow } } 4.BinarySearch가 무엇인지 찾아보고, 가능하면 한번 구현해보도록 합시다.(가능하면!) -이진 탐색은 제어검색에서 가장 대표적인 방법으로 한번 비교동작이 끝난 후 그 결과를 이용하여 다음에 비교할 대상을 선택하는 방법으로 검색한다. 주어진 파일들을 일정한 순서대로 배열된 상태에서 원하는 값을 검색하는 방법이다. •아래와 같은 출력이 나오는 프로그램을 어떻게하면 짤 수 있는지 생각해서 써보도록 합시다. 그 방법이 확실하다고 생각되면 짜보아도 좋아요 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 - 5X5배열을 우선 배정, 1,2,3,4,5를 우선 0행에 출력, 마지막 4행에 도달했을 때 4열 출력, 마지막 4행에 도달했을 때 4행 출력, 0행에 도달했을 때 (전체 행수-1)만큼 출력 ... 반복....