U E D R , A S I H C RSS

새싹교실/2012/start Line

1. /startLine

  • :
  • :
  • : 환희, 훈, ,

2.1. 1회-환희, 훈 (2012-03-21)

2.1.1.

  • .
  • wiki .
  • 0 1 (ASCII code).
  • .
  • .
  • , (printf, scanf)트 함(assert).
  • 트 함 .

2.1.2.

  • .

2.1.3.

  • , . . . ... . -
  • ㅋㅋㅋㅋㅋ -
  • ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ - 환희

2.2. 1회- (2012-03-22)

2.2.1.

  • .
  • (, ) 확.
  • 확하 (함, call by value, call by reference, , 포)

2.2.2.

  • C .

2.2.3.

  • - C , 함 , , gcc . 한 함 . . .
  • - . .

2.3. 2회-환희 (2012-03-26)

2.3.1.

  • 1회 .
  • .
  • (, ) (switch break , ).
  • .

2.3.2.

  • - . -_-

int main()
{
   int num1 , num2 = 1, num3, num4 = 2;

   printf("   \n");
   scanf("%d", &num1);

   num3 = num1 - 1;

   while(num2 <= num1){
      while(num3 < num1){
         printf("*");
         num3++;
      }
      printf("\n");
      num3 = num3 - num4;
      num2 = num2 + 1;
      num4++;
   }

   return 0;
}

2.3.3.

  • 환희 - 편하 .
  • - (if, switch.. for...) (switch break, ..) 환희 ( , python, c함) 1:1 편했. 환희 . C if for . printf, scanf c 편했.

2.4. 3회-환희 (2012-3-28)

2.4.1.

  • .
  • / .
  • .
  • .
  • swap 함 통해 .

2.4.2.

  • .

2.4.3.

  • (if, ) . , 함 . . 환희 . scope . printf . 할텐 . . -
  • 험했
    - ,
    - 함? 함 ,
    -
    - 해 ......? - 환희

2.5. 3회-훈, (2012-3-28)

2.5.1.

  • , .
  • swap 함 .
  • , .
  • malloc 함 .
  • .

2.5.3.

  • , . swap 함 . 함 . , call-by-value . 통해 통해 (call-by-reference) . malloc . 확히 해했 . , 확한 . C C . . -
  • 한 swap 함 , 환. malloc 형태 힘. malloc . -
  • , 포 , malloc 함, fflush() 함, getchar() 함, heap stack , (int)a *(*(int a)) , 포 OS(DWORD 크 . 32bit/64bit),
    - , , . -

2.6. 4회-환희 (2012-4-2)

2.6.1.

  • swap 함 .
  • (call-by-value).
  • , .
  • 환희 .

2.6.2.

  • C 환희 C . 확히 ... -

2.6.3.

  • swap 함 swap 함 . . call-by-value . 편한 . malloc 행할 환희 . . . C . -
  • - .
    .
    + - + ... 해했. - 환희

2.7. 4회-훈 (2012-4-3)

2.7.2.


*, & ( ..) ..
malloc fflush 함 확하
히 heap stack .

... ㅋㅋㅋㅋㅋㅋㅋㅋㅋ -

2.7.3.

  • - .

// 함 
void reverseArr(int **arr, int arrLen);

// 함 
int arr[10];
reverseArr(&arr, 10);

2.8. 5회-환희 (2012-4-4)

2.8.1.

  • malloc 함.
  • .
  • .

2.8.2.

  • 화 하 (malloc 함 ) (free 함) . , . () , . -
  • malloc 함 = 힙 , (?)
    Pointer = .
    (포) = , |
    . - 환희

2.9. 5회-훈 (2012-4-5)

2.9.1.

  • .
  • , (struct 키, ., typedef 키).
  • (changeAge()함 통해 함).
  • .

2.9.2.

  • 2회. 포 typedef . . typedef int* SOMETHING , . 히 int **twoDim twoDim0 malloc . . (*s).age . -> * . . . -
  • , , "#" . 한 typedef .
.
  • 학하 1. ... C . ㅋ하. -

2.10. 4회- (2012-4-5)

2.10.1.

  • malloc 함.
  • , , typedef 키.
  • .

2.10.2.

  • . () , . . -
  • (malloc) , , typedef 통해 . , . . -

2.11. 6회-환희 (2012-4-9) + 7회-환희 (2012-4-9)

2.11.1.

  • .
  • .
  • (operation).
  • .
  • fopen() 함 .

2.11.2.

  • 환희 . ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
  • , . ;;;; 환희 . 화 한 () (함) . . 한 템( ) , . . -

2.12. 8회 (2012-5-1) - 훈, 환희

2.12.1.

  • .
  • - 함.
  • (함) .
  • .
  • (isPrime, isPalindromePrime ).

2.12.2.

  • 험했 : 함 . . 포 .
    : reverse(number) -
    : 희......했 , 함 . C . . -
  • '함' . . (함) . , . . -

2.12.3.

  • .
  • reverse 함 .

    . .

//      .
// 123  321 . 100  1 . 120  21 .
int reverse(int number);

2.13. 9회(2012-5-9) - 훈, 환희

2.13.1.

  • callback, event driven .
  • (char *) .
  • 한 함(str...).
  • winapi.co.kr

2.13.2.

  • Callback(winapi ) + winapi.co.kr
    5. + .
    ... .
    . - 환희
  • 한 함 CallBack .
    .
    C function 해하 .
    . -
  • 행했. . , . . C 한 char * (함) . -

2.13.3. -

  • Calender.h 파 - 할 함. .

// 한   .
void printCalender(int nameOfDay, int year, int month);
//    (nameOfDay)     1~endDayOfMonth .
void printDate(int nameOfDay, int endDayOfMonth);
//  1      탭('\t') .
void printFirstTab(int nameOfDay);
//    (, , 한 , ) .
void printHeader(int year, int month);
//      환합.
int calculateNameOfNextMonthFirstDay(int nameOfDay, int year, int month);
// 해     환합.
int calculateNameOfLastDay(int nameOfDay, int year, int month);
//  크.
bool isLeapYear(int year);
//      환합.
// 한 switch-case  , 2   .
int endDayOfMonth(int year, int month);
//       환합. (ex. 0-"Sun", 1-"Mon" ...)
// 한 switch-case  .
char *printMonthName(int i);
  • main.cpp 파

#include <stdio.h>
#include "Calender.h"

int main(int argc, char *args[]) {
	// year (nameOfDay)  .
	int year = 0, nameOfDay = 0;
	printf("Enter the year : ");
	scanf("%d", &year);
	printf("Enter the name of day(0:sun ~ 6:sat) : ");
	scanf("%d", &nameOfDay);

	// 1~12  .
	for ( int month = 1; month <= 12; month++ ) {
		printCalender(nameOfDay, year, month);
		nameOfDay = calculateNameOfNextMonthFirstDay(nameOfDay, year, month);
	}

	return 0;
}
  • sample output - 1 12. 탭('\t') .

                 January, 2012
-------------------------------------------------
  Sun    Mon    Tue    Wed    Thu    Fri    Sat
   1      2      3      4      5      6      7
   8      9     10     11     12     13     14
  15     16     17     18     19     20     21
  22     23     24     25     26     27     28
  29     30     31

2.13.4.

  • strcat(str1, str2) str1 트했 .
    People p; strcat . p 화(People p = {0};) 하
    p.name . strcat p.name (p.name99 ) "홍" .
    p 화 하 memset(p.name, 0, sizeof(char)*100); .


#include <stdio.h>
#include <string.h>

typedef struct People{
	char gender;
	int age;
	char name[100];
	char real_name[100];
} People;

int main()
{
	char str1[100] = "abc";
	char str2[100] = "aaa";

	People p;
	strcat(p.name, "홍");

	strcat(str1, str2);

	printf("%s", str1);

	getchar();
	return 0;
}

2.14. 10회(2012-5-22) - 훈, 환희

2.14.1.


  • .
  • .
    addAccount() deleteAccount() 한 하 .

Account.h
#include <stdio.h>

typedef struct Account {
	char *name;
	int money;
} Account;

typedef struct AccountArray {
	struct Account **accounts;
	int currentAccountNumber;
	int maxLength; //        편하.
} AccountArray;

Account *createAccount(char *name); // Account     .
AccountArray *createAccountArray(int maxLength);
void addAccount(AccountArray *accountArray, char *name);
bool isFull(AccountArray *accountArray); //     ??????
AccountArray *extendArray(AccountArray *before); //    .
void deleteAccount(AccountArray *accountArray, char *name); //    ?     ?
void deposit(AccountArray *accountArray, char *name, int money); // accountArray    .
void withdraw(AccountArray *accountArray, char *name, int money);

void addAccountMenu();
void deleteAccountMenu();
void depositMenu();
void withdrawMenu();

main.cpp
#include <stdio.h>

#include "Account.h"

int main(int argc, char *argv[]) {
    int select = 0;
	//    .

    while ( true ) {
        printf("select menu : ");
		printf("1:  \n");
		printf("2:  \n");
		printf("3: \n");
		printf("4: \n");
        scanf("%d", &select);

        switch ( select ) {
		case 1:
			addAccountMenu();
			break;
		case 2:
			deleteAccountMenu();
			break;
		case 3:
			depositMenu();			
			break;
		case 4:
			withdrawMenu();
			break;
                default:
                        break;
		}
    }

	return 0;
}

2.15. 11회(2012-5-23) - 훈, 환희

2.15.1.

//////////////////////////////////////  ,   + 포
char a; // a ? 1.  a .
a = ?? //  화 해 .
int b; // b ? 1.  b .
b = ?? //  화 해 .

char c[10]; // c ?, 1.   0 화 해 ., 2.    화 해 ., 3. c[0] ?
char *d; // d ? char 10     화 해 .

// c d   . .


??? // []  c    .
??? //  d    .
??? //  c    .
// array[0] == *(array + 0)       .



////////////////////////////////////////   ,    + 포
Person p; // p ? 1.  p  .
??? // p  .

Person pArr[10]; // pArr ? 1.  pArr  .
??? // pArr 0  

Person *p2; // p2 ? 1.  p2  .
??? // p2 화 해 .
??? // p2  .



Person *ppa[10] // ppa ? 1.  ppa  ., 2. ppa[0] ? 3. ppa[0] 화 해 . 4. ppa[0]  .

Person **ppb // ppb ? 1.  ppb  ., 2. ppb[0] ? 3. ppb[0] 화 해 ., 4. ppb[0]  .

2.16. 12회(2012-7-19)

2.16.1.

  • AccountArray .
  • createAccount(char *name) Account * 환하.

Account makeAccount(char *name) {
	Account account;
	account.money = 0;
	account.name = (char *)malloc(sizeof(char) * (strlen(name)+1));
	strcpy(account.name, name);

	return account;
}

void addMoney(Account account, int money) {
	account.money += money;
}
Account 환하 .
Account call-by-value Account money
Account .
  • extendArray 편함.

2.17. 13회(2012-7-20)

2.17.1.


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef int Data;

typedef struct Node {
    Data data;
    Node *nextNode;
} Node;

typedef struct LinkedList {
    int length;
    Node *headNode;
} LinkedList;

LinkedList *createList();
Node *createNode(Data data);
void deleteList(LinkedList *linkedList); // LinkedList .
void addData(LinkedList *linkedList, Data data); // LinkedList   Data  Node .
void removeData(LinkedList *linkedList, Data data); // 해 Data  Node .
Node *getData(LinkedList *linkedList, int position); // 해 index  Node 환.
void clearList(LinkedList *linkedList); // LinkedList Node .
void printList(LinkedLIst *linkedList);

2.17.2.

  • 환희




#include "LL.h"

LinkedList *createList(){
	LinkedList *res;
	res = (LinkedList *)malloc( sizeof(LinkedList) );
	(*res).headNode = NULL;
	(*res).length = 0;	
	return res;
}
Node *createNode(Data data){
	Node *res;
	res = (Node *)malloc( sizeof(Node) );
	(*res).data = 0;
	(*res).nextNode = NULL;
	return res;
}
void deleteList(LinkedList *linkedList){
	clearList(linkedList);
	free(linkedList);
}
void addData(LinkedList *linkedList, Data data){
	Node *node = createNode( data );
	Node *temp = linkedList->headNode;
	for(;temp->nextNode != NULL;){
		temp = temp->nextNode;
	}
	temp->nextNode = node;
}
void removeData(LinkedList *linkedList, Data data){
	int onoff = 0;																		//for duty of switch
	Node *remove = linkedList->headNode;
	if( remove->data == data ){
		free( remove );																	//If the object is headNode
		onoff = 1;
	}
	if( onoff == 0 && remove->nextNode->data == data ){
		free( remove->nextNode );														//If the object is the nextNode of headNode
		onoff = 1;
	}
	for(; onoff == 0 && remove->nextNode->data != data;){								//...
		remove = remove->nextNode;
	}
	remove->nextNode = remove->nextNode->nextNode;										//	remove   remove-n   remove-n-n
	free(remove->nextNode);																//	remove ~ remove-n-n , free remove-n
}
Node *getData(LinkedList *linkedList, int position){
	Node *get = linkedList->headNode;
	for( int i = 0 ; i < position ; i++ ){
		get = get->nextNode;
	}
	return get;
}
void clearList(LinkedList *linkedList) {
	Node *now = (*linkedList).headNode;
	Node *next;
	for( ; (*now).nextNode != NULL ; ){	//now   
		next = (*now).nextNode;			//next now 
		free( now );					//now free
		now = next;						//next now 
	}
	free( now );						//now free
}
int lengthOf(LinkedList *linkedList){
	int length = 0;
	Node *temp = linkedList->headNode;
	for( ; temp->nextNode != NULL ; length++ ){
		temp = temp->nextNode;
	}
	return length;
}
void printList(LinkedList *linkedList){
	Node *temp = linkedList->headNode;
	for( ; temp->nextNode != NULL ; ){
		printf("%d\t", temp->data);
		temp = temp->nextNode;
	}
	printf("\n");
}

2.17.3.

  • , .

2.18. 2012-7-30

2.18.1.

int main() {
	Stack *stack = createStack();
	assert(stack->elementNumber == 0);
	assert(stack->head == NULL);

	push(stack, 10);
	assert(stack->elementNumber == 1);
	assert(peek(stack)->data == 10);

	push(stack, 20);
	assert(stack->elementNumber == 2);
	assert(peek(stack)->data == 20);

	assert(pop(stack)->data == 20);
	assert(stack->elementNumber == 1);

	Node *result = pop(stack);
	assert(result->data == 10);
	assert(isEmpty(stack));

	return 0;
}

2.19. 2012-8-2

2.19.1.

  • Map in C - . .


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:48
Processing time 0.0821 sec