본문 바로가기

전체 글

(453)
도전! 프로그래밍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", ..
알파벳 찾기 #include using namespace std; int main() { char s[101] = { 0 }; int a[26]; int i, j; cin >> s; for (i = 0; i < 26; i++) //배열 초기화 a[i] = -1; for (i = 'a'; i
숫자의 합 #include using namespace std; int main() { char str[100] = { 0 }; int i, num; int sum = 0; cin >> num; cin >> str; for (i = 0; i < num; i++) { sum += str[i]-'0'; } cout
아스키 코드 #include using namespace std; int main() { char a; cin >> a; cout
하노이 탑 이동 순서 #include using namespace std; void hanoi(int num, int a, int b, int c) { if (num == 1) cout
별 찍기 - 10 #include using namespace std; char arr[3000][3000]; void empty(int num) // 빈 공간 생성 { for (int i = 0; i < num; i++) for (int j = 0; j < num; j++) arr[i][j] = ' '; } void draw(int num, int x, int y) //별 그리기 { if (num == 1) { arr[x][y] = '*'; return; } int N = num / 3; //3으로 나눔 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i == 1 && j == 1) continue; // i가 1이고 j가 1이면 공백 draw(N, x ..
팩토리얼 #include using namespace std; int Factorial(int n) { if (n == 0) return 1; else return n*Factorial(n - 1); } int main() { int num; cin >> num; cout