Programming15 Alone Study-1 //출력 public class Study1 { public static void main(String [] args) { System.out.println("Hello World!"); } } //문자열 출력 public class Study1 { public static void main(String [] args) { String apple = "사과"; int a =3; String fruit = apple + a + "개"; System.out.println(fruit); } } //배열 public class Study1 { public static void main(String [] args) { int a[] = {1,2,3,4}; System.out.println(a[0]); System.. 2012. 12. 22. Circular Queue 환영큐 #include #define Max_Q 5 int Q[Max_Q]; int bot, top; void firstQ() { bot = top = 0; } void clearQ() { bot = top; } int push(int n) { if((top+1)%Max_Q==bot){ printf("꽉참\n"); return -1; } Q[top] = n; top++; top = top%Max_Q; return n; } int pop() { int n; if( bot == top){ printf("빔\n"); return -1; } n=Q[bot]; bot++; bot = bot%Max_Q; return n; } int main() { firstQ(); push(1); push(2); push(3); .. 2012. 12. 21. Stack /*스택 소스*/ #include #include #define MAX_STACK_SIZE 26 char stack[MAX_STACK_SIZE]; int top=-1; void push(char item){ if(top >= MAX_STACK_SIZE){ printf("\n\n Stack is Full! \n"); return; }else stack[++top] = item; } char pop() { if(top==-1){ printf("\n\n Stack is empty!!\n"); return 0; }else return stack[top--]; } int main(void) { char i; for(i=65;i 2012. 12. 20. 이전 1 2 3 4 다음