Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

자료구족발보쌈/0812: Difference between revisions

From ZeroWiki
imported>박인서
No edit summary
imported>박인서
No edit summary
Line 63: Line 63:


== 박인서 ==
== 박인서 ==
 
=== DFS ===
//이게 ㄹㅇ 고통
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int val;
struct node* lnext;
struct node* rnext;
}node;
void givelchild(node *, int);
void giverchild(node *, int);
int find(node * ,int);
int main()
{
int a;
node head;
head.val=1;
head.lnext=NULL;
head.rnext=NULL;
givelchild(&head,2);
giverchild(&head,3);
givelchild(head.lnext,4);
giverchild(head.rnext,5);
scanf("%d",&a);
printf("%d ",find(&head,a));
return 0;
}
void givelchild(node * target, int newval)
{
node * newnode=(node *)malloc(sizeof(node));
newnode->val=newval;
target->lnext=newnode;
newnode->lnext=NULL;
newnode->rnext=NULL;
}
void giverchild(node * target, int newval)
{
node * newnode=(node *)malloc(sizeof(node));
newnode->val=newval;
target->rnext=newnode;
newnode->lnext=NULL;
newnode->rnext=NULL;
}
int find(node * target,int findint)
{
int flag=0;
if(target->val==findint) return 1;
if(target->lnext==NULL && target->rnext==NULL) return 0;
if(target->lnext!=NULL) flag+=find(target->lnext,findint);
if(target->rnext!=NULL) flag+=find(target->rnext,findint);
if(flag==0) return 0;
else return 1;
}
=== BFS ===
== 이정재 ==
== 이정재 ==



Revision as of 06:49, 12 August 2015

  ~~드디어 진짜 고통~~

참여자 명단

함장 장용운 11학번 지각
선원 천준현 15학번 행방불명
최지혁 장염
박인서 출석
이정재 출석
이원준 출석
조종현 시차적응
남헌 친척집

~~매주 1명씩 장염에 걸린다~~

수업

진행

  1. 장소 : 6층 학회실
  2. 시간 : 14시 20분 ~

내용

수심 3000m. 트리

  • (b-)트리 만들기
  • 문제해결

코드

예제1

숙제

  1. 복습하기
  2. 복습하기
  3. 복습하기


숙제 제출

천준현

최지혁

박인서

DFS

//이게 ㄹㅇ 고통
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
	int val;
	struct node* lnext;
	struct node* rnext;
}node;

void givelchild(node *, int);
void giverchild(node *, int);
int find(node * ,int);

int main()
{
	int a;
	node head;
	head.val=1;
	head.lnext=NULL;
	head.rnext=NULL;
	givelchild(&head,2);
	giverchild(&head,3);
	givelchild(head.lnext,4);
	giverchild(head.rnext,5);
	scanf("%d",&a);
	printf("%d ",find(&head,a));
	return 0;
}

void givelchild(node * target, int newval)
{
	node * newnode=(node *)malloc(sizeof(node));
	newnode->val=newval;
	target->lnext=newnode;
	newnode->lnext=NULL;
	newnode->rnext=NULL;
}

void giverchild(node * target, int newval)
{
	node * newnode=(node *)malloc(sizeof(node));
	newnode->val=newval;
	target->rnext=newnode;
	newnode->lnext=NULL;
	newnode->rnext=NULL;
}

int find(node * target,int findint)
{
	int flag=0;
	if(target->val==findint) return 1;
	if(target->lnext==NULL && target->rnext==NULL) return 0;
	if(target->lnext!=NULL) flag+=find(target->lnext,findint);
	if(target->rnext!=NULL) flag+=find(target->rnext,findint);
	if(flag==0) return 0;
	else return 1;
}

BFS

이정재

이원준

조종현

남헌



활동지도/2015 자료구족발보쌈