SW Study (30) 썸네일형 리스트형 도전! 프로그래밍4 도전3 #include #include typedef struct complxnum { double real; double imaginary; } ComplxNum; ComplxNum Add(ComplxNum num1, ComplxNum num2) { ComplxNum add; add.real = num1.real + num2.real; add.imaginary = num1.imaginary + num2.imaginary; return add; } ComplxNum Mul(ComplxNum num1, ComplxNum num2) { ComplxNum mul; mul.real = (num1.real*num2.real) - (num1.imaginary*num2.imaginary); mul.imaginary = (n.. 도전! 프로그래밍4 도전2 #include #include typedef struct booklist { char author[20]; char title[50]; int page; } BookList; void BookInfo(BookList *pbook) { printf("author: "); scanf("%s", pbook->author); printf("title: "); scanf("%s", pbook->title); printf("page: "); scanf("%d", &pbook->page); } void ShowBookInfo(BookList pbook) { printf("author: %s \n", pbook.author); printf("title: %s \n", pbook.title); printf("page:.. 도전! 프로그래밍4 도전1 #include typedef struct booklist { char author[20]; char title[50]; int page; } BOOKLIST; void BookInfo(BOOKLIST *pbook) { printf("author: "); scanf("%s", pbook->author); printf("title: "); scanf("%s", pbook->title); printf("page: "); scanf("%d", &pbook->page); } void ShowBookInfo(BOOKLIST pbook) { printf("author: %s \n", pbook.author); printf("title: %s \n", pbook.title); printf("page: %d \n", .. 도전! 프로그래밍3. 도전 6 #include #include #include int Check(int *Com, int *You, int *Result) //숫자 비교 { int i, j; int strike = 0, ball = 0; for (i = 0; i < 3; i++) //strike, ball 판별 { for (j = 0; j < 3; j++) { if (Com[i] == You[j]) { if (i == j) strike++; else ball++; } } } Result[0] = strike; Result[1] = ball; if (strike == 3) //strike 3일 경우 Result[2] = 1; return 0; } int main(void) { int Com[3] = { 0 }; int You[3] = .. 도전! 프로그래밍3. 도전 5 #include #include #include int Compare(int num1, int num2) //입력 받은 두 수 비교 { if (num1 == 0) //바위 { if (num2 == 1) { return 2; } else if (num2 == 2) { return 0; } else { return 1; } } if (num1 == 1) //가위 { if (num2 == 2) { return 2; } else if (num2 == 0) { return 0; } else { return 1; } } if (num1 == 2) //보 { if (num2 == 0) { return 2; } else if (num2 == 1) { return 0; } else { return 1; } } } int.. 도전! 프로그래밍3. 도전 4 #include #include int main(void) { int i; srand((int)time(NULL)); for (i = 0; i < 2; i++) printf("dice %d: %d \n", i+1, (rand()%6)+1); return 0; } 도전! 프로그래밍3. 도전 3 #include #include int main(void) { int i; printf("randomNum: 0~%d \n", 99); for (i = 0; i < 5; i++) printf("randomNum Output: %d \n", rand()%100); return 0; } 도전! 프로그래밍3. 도전 2 #include void Snail(int (*arr)[100], int num) { int i = 0, j = 0; int x = 0, y = 0; //가로 세로 int count = 1, turn = 0, limit = num; //숫자 세기, 방향, 출력 범위 int sign = 1; //부호 변환 while (count = (num*num)) //출력 범위 초과시 탈출 break; for (j = 1; j < limit; j++) //세로 출력 { arr[x][y] .. 이전 1 2 3 4 다음 목록 더보기