U E D R , A S I H C RSS

자료구족발보쌈/1117

Difference between r1.2 and the current

@@ -97,7 +97,97 @@
}}}

== 이원준 ==
print랑 pop은 없슴다.
{{{
#include<stdio.h>
#include<string.h>
 
typedef struct _norm{
char *name;
struct _norm *next;
}norm;
 
typedef struct _grade{
char grade[3];
struct norm *head;
}grade;
 
void push(grade *head, char key[3], char *name){
 
char *temp = (char *)malloc(sizeof(name) * strlen(name));
norm* dir;
int num;
int i;
 
for (i = 0; i < 8; i++){
if (strcmp(head[i].grade, key) == 0){
num = i;
break;
}
}
 
dir = head[i].head;
strcpy(temp, name);
 
norm *ntemp = (norm *)malloc(sizeof(norm));
ntemp->name = temp;
ntemp->next = NULL;
 
if (dir == NULL){
head[i].head = ntemp;
 
return;
}
 
while (dir->next != NULL){
dir = dir->next;
}
dir->next = ntemp;

}
 
void print_all(grade *head){
int i;
for (i = 0; i < 8; i++){
if (head[i].head == NULL){
printf("없어요.\n");
continue;
}
}
 
}
 
void main(){
grade head[8];
norm* temp;
int i, j;
for (i = 0; i < 8; i++){
head[i].head = NULL;
head[i].grade[0] = 'A' + (i/2);
head[i].grade[2] = '\0';
if (i % 2 == 0)
head[i].grade[1] = '0';
else
head[i].grade[1] = '+';
 
}
head->head = NULL;
push(head, "A+", "lee");
push(head, "A+", "kim");
temp = head[1].head;
printf("%s", temp->name);
 
printf("%s", temp->next->name);
 
}
}}}
== 남헌 ==

----


INTRO


1. 참여자 명단


함장 장용운 11학번 출석
선원 천준현 15학번 결석
박인서 출석
이원준 출석
남헌 탈주닌자

2. 수업

2.1. 진행

1. 장소 : 6층 학회실
2. 시간 : 15시 ~ 17시

2.2. 내용

번외편
  • Set
  • Map

3. 코드

3.1. 예제1


4. 숙제

1. 고통받기




5. 숙제 제출

5.1. 천준현


5.2. 박인서

  • 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;
}

5.3. 이원준

print랑 pop은 없슴다.
#include<stdio.h>
#include<string.h>

typedef struct _norm{
	char *name;
	struct _norm *next;
}norm;

typedef struct _grade{
	char grade[3];
	struct norm *head;
}grade;

void push(grade *head, char key[3], char *name){

	char *temp = (char *)malloc(sizeof(name) * strlen(name));
	norm* dir;
	int num;
	int i;

	for (i = 0; i < 8; i++){
		if (strcmp(head[i].grade, key) == 0){
			num = i;
			break;
		}
	}

	dir = head[i].head;
	
	strcpy(temp, name);

	norm *ntemp = (norm *)malloc(sizeof(norm));
	ntemp->name = temp;
	ntemp->next = NULL;

	if (dir == NULL){
		
		head[i].head = ntemp;

		return;
	}

	while (dir->next != NULL){
		dir = dir->next;
	}
	dir->next = ntemp;

}

void print_all(grade *head){
	int i;
	for (i = 0; i < 8; i++){
		if (head[i].head == NULL){
			printf("없어요.\n");
			continue;
		}
	}

}

void main(){
	grade head[8];
	norm* temp;
	int i, j;
	
	for (i = 0; i < 8; i++){
			head[i].head = NULL;
			head[i].grade[0] = 'A' + (i/2);
			head[i].grade[2] = '\0';
			if (i % 2 == 0)
				head[i].grade[1] = '0';
			else
				head[i].grade[1] = '+';

	}
	head->head = NULL;
	
	push(head, "A+", "lee");
	
	push(head, "A+", "kim");
	
	temp = head[1].head;
	
	printf("%s", temp->name);

	printf("%s", temp->next->name);

}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:39
Processing time 0.0394 sec