본문 바로가기

SW Study/윤성우 C 프로그래밍

(26)
도전! 프로그래밍4 도전7 #include #include #include typedef struct personinfo { char name[20]; char phoneNum[20]; } PersonInfo; void Insert(PersonInfo *man, int * pnum) { printf("[ INSERT ] \n"); printf("Input Name: "); scanf("%s", man[*pnum].name); printf("Input Tel Number: "); scanf("%s", man[*pnum].phoneNum); printf(" Data Inserted \n\n"); (*pnum)++; } void Delete(PersonInfo *man, int * pnum) { char del[20] = { 0 }; ..
도전! 프로그래밍4 도전6 #include #include #include int num; typedef struct personinfo { char name[20]; char phoneNum[20]; } PersonInfo; void Insert(PersonInfo *man) { printf("[ INSERT ] \n"); printf("Input Name: "); scanf("%s", man[num].name); printf("Input Tel Number: "); scanf("%s", man[num].phoneNum); printf(" Data Inserted \n\n"); num++; } void Delete(PersonInfo *man) { char del[20] = { 0 }; int i, j; if (num == 0)..
도전! 프로그래밍4 도전5 #include #include int main(void) { char ch1, ch2; FILE * fp1 = fopen("d1.txt", "rt"); FILE * fp2 = fopen("d2.txt", "rt"); if (fp1 == NULL||fp2 == NULL) { puts("file open error! "); return -1; } while (1) { ch1 = fgetc(fp1); ch2 = fgetc(fp2); if (ch1 != ch2) { printf("Not Coincide \n"); break; } else if (ch1 == EOF&&ch2 == EOF) { printf("Coincide \n"); break; } } fclose(fp1); fclose(fp2); return ..
도전! 프로그래밍4 도전4 #include int main(void) { char word[50]; int numA = 0, numP = 0; FILE * fp = fopen("text.txt", "rt"); if (fp == NULL) { puts("file open error! "); return -1; } while (1) { fscanf(fp, "%s", word); if (feof(fp) != 0) break; else if (word[0] == 'A' || word[0] == 'a') numA++; else if (word[0] == 'P' || word[0] == 'p') numP++; } printf("A start word's num: %d \n", numA); printf("P start word's num: %..
도전! 프로그래밍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] = ..