More actions
imported>박인서 No edit summary |
imported>박인서 No edit summary |
||
| Line 49: | Line 49: | ||
== 박인서 == | == 박인서 == | ||
* bucket sort | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#define LEN 5 | |||
typedef struct data{ | |||
char * student; | |||
struct data * next; | |||
}stu; | |||
void push(stu * data,char * val) | |||
{ | |||
stu * temp=(stu *)malloc(sizeof(stu)); | |||
temp->student=val,temp->next=NULL; | |||
while(data->next!=NULL) data=data->next; | |||
data->next=temp; | |||
} | |||
void print(stu * data) | |||
{ | |||
if(data->next==NULL) return; | |||
printf("%s : ",data->student); | |||
while(data->next->next!=NULL) | |||
{ | |||
data=data->next; | |||
printf("%s, ",data->student); | |||
} | |||
printf("%s\n",data->next->student); | |||
} | |||
int main() | |||
{ | |||
stu data[8]; | |||
char * key=(char *)malloc(sizeof(char)*3); | |||
char * value[LEN]; | |||
int i; | |||
data[0].student="A+",data[1].student="A0"; | |||
data[2].student="B+",data[3].student="B0"; | |||
data[4].student="C+",data[5].student="C0"; | |||
data[6].student="D+",data[7].student="D0"; | |||
for(i=0;i<8;i++) data[i].next=NULL; | |||
for(i=0;i<LEN;i++) value[i]=(char *)malloc(sizeof(char)*100); | |||
for(i=0;i<LEN;i++) | |||
{ | |||
printf("insert %d key\n",i+1); | |||
scanf("%s",key); | |||
printf("insert %d value\n",i+1); | |||
scanf("%s",value[i]); | |||
if(!strcmp(key,"A+")) push(&data[0],value[i]); | |||
if(!strcmp(key,"A0")) push(&data[1],value[i]); | |||
if(!strcmp(key,"B+")) push(&data[2],value[i]); | |||
if(!strcmp(key,"B0")) push(&data[3],value[i]); | |||
if(!strcmp(key,"C+")) push(&data[4],value[i]); | |||
if(!strcmp(key,"C0")) push(&data[5],value[i]); | |||
if(!strcmp(key,"D+")) push(&data[6],value[i]); | |||
if(!strcmp(key,"D0")) push(&data[7],value[i]); | |||
} | |||
for(i=0;i<8;i++) print(&data[i]); | |||
return 0; | |||
} | |||
== 이원준 == | == 이원준 == | ||
Revision as of 04:31, 24 November 2015
__INTRO__
참여자 명단
| 함장 | 장용운 | 11학번 | 출석 |
| 선원 | 천준현 | 15학번 | 결석 |
| 박인서 | 출석 | ||
| 이원준 | 출석 | ||
| 남헌 | 탈주닌자 |
수업
진행
- 장소 : 6층 학회실
- 시간 : 15시 ~ 17시
내용
번외편
- Set
- Map
코드
예제1
숙제
- 고통받기
숙제 제출
천준현
박인서
- bucket sort
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LEN 5
typedef struct data{
char * student;
struct data * next;
}stu;
void push(stu * data,char * val)
{
stu * temp=(stu *)malloc(sizeof(stu));
temp->student=val,temp->next=NULL;
while(data->next!=NULL) data=data->next;
data->next=temp;
}
void print(stu * data)
{
if(data->next==NULL) return;
printf("%s : ",data->student);
while(data->next->next!=NULL)
{
data=data->next;
printf("%s, ",data->student);
}
printf("%s\n",data->next->student);
}
int main()
{
stu data[8];
char * key=(char *)malloc(sizeof(char)*3);
char * value[LEN];
int i;
data[0].student="A+",data[1].student="A0";
data[2].student="B+",data[3].student="B0";
data[4].student="C+",data[5].student="C0";
data[6].student="D+",data[7].student="D0";
for(i=0;i<8;i++) data[i].next=NULL;
for(i=0;i<LEN;i++) value[i]=(char *)malloc(sizeof(char)*100);
for(i=0;i<LEN;i++)
{
printf("insert %d key\n",i+1);
scanf("%s",key);
printf("insert %d value\n",i+1);
scanf("%s",value[i]);
if(!strcmp(key,"A+")) push(&data[0],value[i]);
if(!strcmp(key,"A0")) push(&data[1],value[i]);
if(!strcmp(key,"B+")) push(&data[2],value[i]);
if(!strcmp(key,"B0")) push(&data[3],value[i]);
if(!strcmp(key,"C+")) push(&data[4],value[i]);
if(!strcmp(key,"C0")) push(&data[5],value[i]);
if(!strcmp(key,"D+")) push(&data[6],value[i]);
if(!strcmp(key,"D0")) push(&data[7],value[i]);
}
for(i=0;i<8;i++) print(&data[i]);
return 0;
}