C언어/문제풀다 하나씩
head[100]과 myalloc()해보기
mcdn
2020. 6. 26. 14:01
반응형
#include <iostream>
#include <string>
using namespace std;
struct node {
//char abc;
int num;
node* next;
};
node *head[100];
node *last[100];
node buf[10000];
int bufcnt;
node* myalloc() {
return &buf[bufcnt++];
}
void append(char ab, int value) {
node* temp = myalloc();
temp->next = head[ab];
temp->num = value;
head[ab] = temp;
}
int main() {
append('A', 3);
append('D', 14);
append('C', 36);
append('C', 35);
append('B', 32);
append('E', 34);
append('A', 15);
append('E', 6);
append('E', 15);
append('A', 21);
char ans;
cin >> ans;
int asci = ans;
for (node* p = head[asci]; p != NULL;p = p->next) {
cout << p->num << ' ';
}
return 0;
}
문제는 append를 못 만들겠다는 것...
반응형