SlideShare a Scribd company logo
1 of 9
Download to read offline
보고서
소속 : 자료구조 01분반 D0조

이름 : 20073547 홍진욱 , 20083430 강승우 , 20093447 김도형, 20093489 송하윤 ,20093516 장진승 ,
20073457 김재찬

과제수행기간: 14 일 3번 모임 총     5시간


I. 계획의 작성

 ①연구제목: 관계찾기
 ②연구배경: Database Management System

 ③참고자료:     :   Discrete Mathematics and its applications


 II. 목차

      1. 임무분담에 대하여 ( 2쪽 )


      2. 학습내용에 대하여 ( 3~5쪽 )


      3. 과제 1에 대한 소스 ( 6~8쪽 )


      4. 과제를 마치면서( 마지막 쪽 )


      ※ 모임은 (3/19,3/21) 2번 가졌으며 토의 내용에
        대하여 개인보고서 작성.
※ 임무 분담에 대하여



조장 : 김도형
보고서 작성, 최종 종합.

알고리즘 : 송하윤,김재찬
자연식의 계산 원리를 파악하여 프로그램에 대입하는 역할.


코딩 : 홍진욱
C 코딩 및 프로그램에 대하여 구조 개선 및 문제점 해결.


자료검토 및 스케줄 : 장진승
토론 계획 및 스케줄 관리 준비된 자료 재검토.


검색 및 토의종합 : 강승우
토의 한 내용 기록 및 문제 및 궁금점 조사.
※ 학습내용에 대하여
• binary relation
이항관계


• reflexive
관계 R이 정의된 집합의 모든 원소 a에 대해서 aRa가 성립하는 경우에 대해 R을 반사적 관계(reflexive)라고 한다.


• symmetric
집합의 두 원소 a, b에 대해서 a R b 관계가 성립할 때 b R a의 관계도 성립하면 R을 대칭성 관계라 한다.


• transitive
집합의 세 원소 a, b, c에 대해 a R b와 b R c 관계가 성립하면 a R c의 관계도 성립되는 것.(추이관계)


• equivalence relations
reflexive, symmetric, transitive를 모두 성립하는 관계


• equivalence class of x relative to R
집합R의 각각의 relative를 묶어 분할해 묶어놓은 class


• irreflexive
관계 R이 정의된 집합의 모든 원소 a에 대해서 aRa가 0인 경우에 대해 R을 반사적 관계(reflexive)라고 한다.


• antisymmetric
R이 그 집합에 속하는 임의의 원소 a, b에 대하여 aRb이고, bRb이면 a=b일 때의 관계.
reflexive와 symmetric가 모두 성립하는 관계 예외로는 전제조건이 성립하지 않을 때도 antisymmetric임.


• partial ordering
reflexive, antisymmetric, transitive가 성립하는 관계


• ordering
순서쌍 A|B(a,b)


• lexicographic order
사전식 주문 즉 사전적으로 일정하게 정렬되는 순서.
• transitive closure
집합R이 transitive가 성립하지 않지만 몇 개의 원소를 추가하면 transitive가
성립하게 되면. 이런 식으로 몇 개의 원소를 추가하여 transitive가 성립하는 것 중
가장 작은 집합을 transitive closure라고 합니다.


• composition
집합 A에서 B로의 관계를 A라고 하고, 집합 B에서 C로의 관계를 S라고 하자.
R과 S의 합성관계(composition relation)는 a∈b이고 c∈C일 때,       이고       인
b∈B가 존재하는 순서쌍(a,c)로 구성되는 관계이며, S∘R로 나타낸다.


• identity relation
=reflexive동일하다


• inverse relation
=symmetric과 동일


• function
함수


• image
상


• range
치역


• equal
등호(equal sign)「=」를 쓴다. 좌변과 우변이 같은 것을 표시한다.


• injective
단사함수. 함수의 치역이 공변역의 부분집합이 되며, 정의역에 있는 원소의 개수가
공변역에 있는 원소의 개수보다 작거나 같다.
• surjective
전사함수. 함수의 치역이 공변역과 같으며, 정의역에 있는 원소의 개수가 공변역에
있는 원소의 개수보다 크거나나 같다.


• bijection
전단사함수. 함수의 치역이 공변역과 같으며, 정의역에 있는 원소의 개수와
공변역에 있는 원소의 개수가 같다.


• permutation
서로 다른 n개에서 r개를 뽑아 일렬로 배열하는 방법. 그 방법은 nPr가지이다.
또한 주어진 집합에서 그 집합 자신으로 대응시키는 전단사(全單射) 함수를
말하기도 한다.


• The Pigeonhole Principle
비둘기 집의 원리 : n+1 마리의 비둘기가 n개의 비둘기집에 들어가려면 최소한 한
개의 비둘기집에는 두 마리 이상의 비둘기가 들어가야 한다는 원리.


• invertible
역행렬 : n차의 정방행렬 A에 대하여 AB=BA=I를 만족하는 행렬 B가 존재할 때,
B를 A의 역행렬 이라고 한다.
※ 과제(구조에 대한 설명은 주석처리)
//소스(제작환경 : DEV C++)
#include <stdio.h>


int Find_n(char arr[]);
int Find_m(char arr[]);
void Exch(char crr[],int *p);
void arr_prt(int *p ,int n,int m);
int reflexive(int *p,int n,int m);
int irreflexive(int *p,int n,int m);


int main(){
     //
         //---------------------------data input-----------------------
     char input_data[512];
     int i=0,n,m;
     scanf("%s",&input_data);
/*
     while(1){
           if(input_data[i] == '0')     break;
           printf("%c",input_data[i]);
           i++;
     }
*/


//       printf("n%d %dn",Find_n(input_data),Find_m(input_data));
     n=Find_n(input_data);
     m=Find_m(input_data);
     //------------------------------------------------------------
         //---------------------------create arr-----------------------
     int base_arr[n][m];
/*
     base_arr[0][0] = 11;base_arr[0][1] = 22;
     base_arr[1][0] = 33;base_arr[1][1] = 44;
*/
     int *ba_p;
     ba_p = &base_arr[0][0];
     //------------------------------------------------------------
     //------------------------------------------------------------
     //--------------------------exchange--------------------------
     Exch(input_data,ba_p);
//       arr_prt(ba_p,n,m);


     if(n==m)
           if(reflexive(ba_p,n,m)) printf("reflexive = yesn");
           else printf("reflexive = non");
     else printf("reflexive = non");
     if(n==m)
           if(irreflexive(ba_p,n,m)) printf("irreflexive = yesn");
else printf("irreflexive = non");
     else printf("irreflexive = non");


     int u,y,o,e=0;
         for(u=0; u<n; u++){
                    for(y=0; y<u; y++){
                             if(base_arr[u][y] != base_arr[y][u]){
                                       e = 1;
                                       break
                             }
                    }
         }
     if(e == 1) printf("Symmetric = non");
     else printf("Symmetric = yesn");




//       getch();
     return 0;
}
int reflexive(int *p,int n,int m){
     int i,temp=0,result = 0;
     for(i=0;i<m;i++){
             //printf("%d re %dn",*(p+temp),result);
             if(*(p+temp) != 1 ) result = 1;
             temp = temp + n + 1;
     }
     if(result == 1) return 0;
     else return 1;
}
int irreflexive(int *p,int n,int m){
     int i,temp=0,result = 0;
     for(i=0;i<m;i++){
             if(*(p+temp) != 0 ) result = 1;
             temp = temp + n + 1;
             //printf("%d re %dn",*(p+temp),result);
     }
     if(result == 1) return 0;
     else return 1;
}
//
//
//
void arr_prt(int *p ,int n,int m){
     int i=0,j=0;
     while(1){
             if(i == n*m)    break
             if(i%m == 0){
                 printf("n");
                 j++;
             }
             printf("%d ",*p++);
             i++;
     }
}
//
//

// 변환함수
void Exch(char crr[],int *p){
     int nct=0,i=0,n=0,m=0;
     while(1){
         if(crr[i] == '0')      break
         //if(arr[i] == '[')    continue;
         if(crr[i] == ',')     n++;
         if(crr[i] == ']')     m++;
         if(crr[i] == '1'){
             *p = 1;
             p++;
         }
         if(crr[i] == '0'){
             *p = 0;
             p++;
         }
         i++;
     }
}


//
//
//N x M array sagasuno
int Find_n(char arr[]){
     int nct=0,i=0;
     while(1){
         if(arr[i] == '0')      break
         //if(arr[i] == '[')    continue;
         if(arr[i] == ']')     nct++;
         i++;
     }
     return nct-1;
}
int Find_m(char arr[]){
     int nct=0,i=0;
     while(1){
         if(arr[i] == '0')      break
         //if(arr[i] == '[')    continue;
         if(arr[i] == ',')     nct++;
         if(arr[i] == ']')     break
         i++;
     }
     return nct+1;
}
※ 과제를 마치면서.




- 이번 프로젝트를 하면서 학습내용과 과제를 공부하면서

데이터베이스 시스템에 대하여 이항관계가 어떻게 사용되고

table, tuple과의 상관관계 relational을 이용한 Selection,

Projection, join 등을 만드는 법을 배웠고 과제 1을 통하여

관계(reflexive,   symmetric, transitive)에   대한 알고리즘과 C에 코딩할

때 어떻게 구성하여야 할지를 알 수 있었습니다.




                               감사합니다.

More Related Content

What's hot

DP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfDP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfHo Jeong Im
 
2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdf2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdfkd19h
 
자료구조1보고서
자료구조1보고서자료구조1보고서
자료구조1보고서KimChangHoen
 
2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdfkd19h
 
자료구조 프로젝트
자료구조 프로젝트자료구조 프로젝트
자료구조 프로젝트hyungoh kim
 
6장 표현식 및 문장
6장 표현식 및 문장6장 표현식 및 문장
6장 표현식 및 문장재정 이
 
과제 1,2,3
과제 1,2,3과제 1,2,3
과제 1,2,3mil23
 
How to Study Mathematics for ML
How to Study Mathematics for MLHow to Study Mathematics for ML
How to Study Mathematics for MLDataya Nolja
 
Haskell study 10
Haskell study 10Haskell study 10
Haskell study 10Nam Hyeonuk
 
2012 Ds D2 03
2012 Ds D2 032012 Ds D2 03
2012 Ds D2 03chl132435
 
String Searching Algorithms
String Searching AlgorithmsString Searching Algorithms
String Searching Algorithmsskku_npc
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Circulus
 
HI-ARC PS 102 Brute Force
HI-ARC PS 102 Brute ForceHI-ARC PS 102 Brute Force
HI-ARC PS 102 Brute ForceJae-yeol Lee
 
Support Vector Machine Tutorial 한국어
Support Vector Machine Tutorial 한국어Support Vector Machine Tutorial 한국어
Support Vector Machine Tutorial 한국어Jungkyu Lee
 

What's hot (18)

DP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfDP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdf
 
HI-ARC PS 101
HI-ARC PS 101HI-ARC PS 101
HI-ARC PS 101
 
2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdf2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdf
 
2012 Ds 01
2012 Ds 012012 Ds 01
2012 Ds 01
 
자료구조1보고서
자료구조1보고서자료구조1보고서
자료구조1보고서
 
2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf
 
이산치1번
이산치1번이산치1번
이산치1번
 
자료구조 프로젝트
자료구조 프로젝트자료구조 프로젝트
자료구조 프로젝트
 
6장 표현식 및 문장
6장 표현식 및 문장6장 표현식 및 문장
6장 표현식 및 문장
 
과제 1,2,3
과제 1,2,3과제 1,2,3
과제 1,2,3
 
How to Study Mathematics for ML
How to Study Mathematics for MLHow to Study Mathematics for ML
How to Study Mathematics for ML
 
Haskell study 10
Haskell study 10Haskell study 10
Haskell study 10
 
2012 Ds D2 03
2012 Ds D2 032012 Ds D2 03
2012 Ds D2 03
 
String Searching Algorithms
String Searching AlgorithmsString Searching Algorithms
String Searching Algorithms
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체
 
HI-ARC PS 102 Brute Force
HI-ARC PS 102 Brute ForceHI-ARC PS 102 Brute Force
HI-ARC PS 102 Brute Force
 
Haskell study 9
Haskell study 9Haskell study 9
Haskell study 9
 
Support Vector Machine Tutorial 한국어
Support Vector Machine Tutorial 한국어Support Vector Machine Tutorial 한국어
Support Vector Machine Tutorial 한국어
 

Viewers also liked

Viewers also liked (9)

Tecnologia iii
Tecnologia iiiTecnologia iii
Tecnologia iii
 
Tecnologia ii
Tecnologia iiTecnologia ii
Tecnologia ii
 
2012 Dm A0 06 Pdf
2012 Dm A0 06 Pdf2012 Dm A0 06 Pdf
2012 Dm A0 06 Pdf
 
Tecnologia ii
Tecnologia iiTecnologia ii
Tecnologia ii
 
2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdf2012 Dm A0 04 Pdf
2012 Dm A0 04 Pdf
 
Tecnologia iii
Tecnologia iiiTecnologia iii
Tecnologia iii
 
2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf
 
2012 Dm A0 07 Pdf
2012 Dm A0 07 Pdf2012 Dm A0 07 Pdf
2012 Dm A0 07 Pdf
 
Tecnologia ii
Tecnologia iiTecnologia ii
Tecnologia ii
 

Similar to 2012 Dm A0 02 Pdf

프로젝트 보고서
프로젝트 보고서프로젝트 보고서
프로젝트 보고서hyungoh kim
 
2012 Ds B1 01
2012 Ds B1 012012 Ds B1 01
2012 Ds B1 01seonhyung
 
2012 Ds A1 05
2012 Ds A1 052012 Ds A1 05
2012 Ds A1 05seonhyung
 
Project#3 How Fast Can We Sort Hwp
Project#3 How Fast Can We Sort HwpProject#3 How Fast Can We Sort Hwp
Project#3 How Fast Can We Sort HwpKimjeongmoo
 
자료구조5보고서
자료구조5보고서자료구조5보고서
자료구조5보고서KimChangHoen
 
Project#5 최단거리 찾기 D0 Hwp
Project#5 최단거리 찾기 D0 HwpProject#5 최단거리 찾기 D0 Hwp
Project#5 최단거리 찾기 D0 HwpKimjeongmoo
 
이산수학 D1 프로젝트 2
이산수학 D1 프로젝트 2이산수학 D1 프로젝트 2
이산수학 D1 프로젝트 2pkok15
 
자료구조 Project1
자료구조 Project1자료구조 Project1
자료구조 Project1KoChungWook
 
1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)fmbvbfhs
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조영기 김
 
2012 Dm C3 03
2012 Dm C3 032012 Dm C3 03
2012 Dm C3 03chl132435
 
2012 Ds B2 02 Pdf
2012 Ds B2 02 Pdf2012 Ds B2 02 Pdf
2012 Ds B2 02 Pdfkd19h
 
2012 Ds B2 02
2012 Ds B2 022012 Ds B2 02
2012 Ds B2 02chl132435
 
Spherical Harmonics.pdf
Spherical Harmonics.pdfSpherical Harmonics.pdf
Spherical Harmonics.pdfBongseok Cho
 

Similar to 2012 Dm A0 02 Pdf (20)

프로젝트 보고서
프로젝트 보고서프로젝트 보고서
프로젝트 보고서
 
2012 Ds B1 01
2012 Ds B1 012012 Ds B1 01
2012 Ds B1 01
 
2012 Ds A1 05
2012 Ds A1 052012 Ds A1 05
2012 Ds A1 05
 
Project#3 How Fast Can We Sort Hwp
Project#3 How Fast Can We Sort HwpProject#3 How Fast Can We Sort Hwp
Project#3 How Fast Can We Sort Hwp
 
3콤비네이션
3콤비네이션3콤비네이션
3콤비네이션
 
자료구조5보고서
자료구조5보고서자료구조5보고서
자료구조5보고서
 
이산수학02
이산수학02이산수학02
이산수학02
 
Project#5 최단거리 찾기 D0 Hwp
Project#5 최단거리 찾기 D0 HwpProject#5 최단거리 찾기 D0 Hwp
Project#5 최단거리 찾기 D0 Hwp
 
이산수학 D1 프로젝트 2
이산수학 D1 프로젝트 2이산수학 D1 프로젝트 2
이산수학 D1 프로젝트 2
 
자료구조 Project1
자료구조 Project1자료구조 Project1
자료구조 Project1
 
DM_02
DM_02DM_02
DM_02
 
1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)
 
자구2번
자구2번자구2번
자구2번
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조
 
2012 Dm 02
2012 Dm 022012 Dm 02
2012 Dm 02
 
2012 Dm C3 03
2012 Dm C3 032012 Dm C3 03
2012 Dm C3 03
 
2012 Ds B2 02 Pdf
2012 Ds B2 02 Pdf2012 Ds B2 02 Pdf
2012 Ds B2 02 Pdf
 
2012 Ds B2 02
2012 Ds B2 022012 Ds B2 02
2012 Ds B2 02
 
이산수학03
이산수학03이산수학03
이산수학03
 
Spherical Harmonics.pdf
Spherical Harmonics.pdfSpherical Harmonics.pdf
Spherical Harmonics.pdf
 

2012 Dm A0 02 Pdf

  • 1. 보고서 소속 : 자료구조 01분반 D0조 이름 : 20073547 홍진욱 , 20083430 강승우 , 20093447 김도형, 20093489 송하윤 ,20093516 장진승 , 20073457 김재찬 과제수행기간: 14 일 3번 모임 총 5시간 I. 계획의 작성 ①연구제목: 관계찾기 ②연구배경: Database Management System ③참고자료: : Discrete Mathematics and its applications II. 목차 1. 임무분담에 대하여 ( 2쪽 ) 2. 학습내용에 대하여 ( 3~5쪽 ) 3. 과제 1에 대한 소스 ( 6~8쪽 ) 4. 과제를 마치면서( 마지막 쪽 ) ※ 모임은 (3/19,3/21) 2번 가졌으며 토의 내용에 대하여 개인보고서 작성.
  • 2. ※ 임무 분담에 대하여 조장 : 김도형 보고서 작성, 최종 종합. 알고리즘 : 송하윤,김재찬 자연식의 계산 원리를 파악하여 프로그램에 대입하는 역할. 코딩 : 홍진욱 C 코딩 및 프로그램에 대하여 구조 개선 및 문제점 해결. 자료검토 및 스케줄 : 장진승 토론 계획 및 스케줄 관리 준비된 자료 재검토. 검색 및 토의종합 : 강승우 토의 한 내용 기록 및 문제 및 궁금점 조사.
  • 3. ※ 학습내용에 대하여 • binary relation 이항관계 • reflexive 관계 R이 정의된 집합의 모든 원소 a에 대해서 aRa가 성립하는 경우에 대해 R을 반사적 관계(reflexive)라고 한다. • symmetric 집합의 두 원소 a, b에 대해서 a R b 관계가 성립할 때 b R a의 관계도 성립하면 R을 대칭성 관계라 한다. • transitive 집합의 세 원소 a, b, c에 대해 a R b와 b R c 관계가 성립하면 a R c의 관계도 성립되는 것.(추이관계) • equivalence relations reflexive, symmetric, transitive를 모두 성립하는 관계 • equivalence class of x relative to R 집합R의 각각의 relative를 묶어 분할해 묶어놓은 class • irreflexive 관계 R이 정의된 집합의 모든 원소 a에 대해서 aRa가 0인 경우에 대해 R을 반사적 관계(reflexive)라고 한다. • antisymmetric R이 그 집합에 속하는 임의의 원소 a, b에 대하여 aRb이고, bRb이면 a=b일 때의 관계. reflexive와 symmetric가 모두 성립하는 관계 예외로는 전제조건이 성립하지 않을 때도 antisymmetric임. • partial ordering reflexive, antisymmetric, transitive가 성립하는 관계 • ordering 순서쌍 A|B(a,b) • lexicographic order 사전식 주문 즉 사전적으로 일정하게 정렬되는 순서.
  • 4. • transitive closure 집합R이 transitive가 성립하지 않지만 몇 개의 원소를 추가하면 transitive가 성립하게 되면. 이런 식으로 몇 개의 원소를 추가하여 transitive가 성립하는 것 중 가장 작은 집합을 transitive closure라고 합니다. • composition 집합 A에서 B로의 관계를 A라고 하고, 집합 B에서 C로의 관계를 S라고 하자. R과 S의 합성관계(composition relation)는 a∈b이고 c∈C일 때,   이고   인 b∈B가 존재하는 순서쌍(a,c)로 구성되는 관계이며, S∘R로 나타낸다. • identity relation =reflexive동일하다 • inverse relation =symmetric과 동일 • function 함수 • image 상 • range 치역 • equal 등호(equal sign)「=」를 쓴다. 좌변과 우변이 같은 것을 표시한다. • injective 단사함수. 함수의 치역이 공변역의 부분집합이 되며, 정의역에 있는 원소의 개수가 공변역에 있는 원소의 개수보다 작거나 같다.
  • 5. • surjective 전사함수. 함수의 치역이 공변역과 같으며, 정의역에 있는 원소의 개수가 공변역에 있는 원소의 개수보다 크거나나 같다. • bijection 전단사함수. 함수의 치역이 공변역과 같으며, 정의역에 있는 원소의 개수와 공변역에 있는 원소의 개수가 같다. • permutation 서로 다른 n개에서 r개를 뽑아 일렬로 배열하는 방법. 그 방법은 nPr가지이다. 또한 주어진 집합에서 그 집합 자신으로 대응시키는 전단사(全單射) 함수를 말하기도 한다. • The Pigeonhole Principle 비둘기 집의 원리 : n+1 마리의 비둘기가 n개의 비둘기집에 들어가려면 최소한 한 개의 비둘기집에는 두 마리 이상의 비둘기가 들어가야 한다는 원리. • invertible 역행렬 : n차의 정방행렬 A에 대하여 AB=BA=I를 만족하는 행렬 B가 존재할 때, B를 A의 역행렬 이라고 한다.
  • 6. ※ 과제(구조에 대한 설명은 주석처리) //소스(제작환경 : DEV C++) #include <stdio.h> int Find_n(char arr[]); int Find_m(char arr[]); void Exch(char crr[],int *p); void arr_prt(int *p ,int n,int m); int reflexive(int *p,int n,int m); int irreflexive(int *p,int n,int m); int main(){ // //---------------------------data input----------------------- char input_data[512]; int i=0,n,m; scanf("%s",&input_data); /* while(1){ if(input_data[i] == '0') break; printf("%c",input_data[i]); i++; } */ // printf("n%d %dn",Find_n(input_data),Find_m(input_data)); n=Find_n(input_data); m=Find_m(input_data); //------------------------------------------------------------ //---------------------------create arr----------------------- int base_arr[n][m]; /* base_arr[0][0] = 11;base_arr[0][1] = 22; base_arr[1][0] = 33;base_arr[1][1] = 44; */ int *ba_p; ba_p = &base_arr[0][0]; //------------------------------------------------------------ //------------------------------------------------------------ //--------------------------exchange-------------------------- Exch(input_data,ba_p); // arr_prt(ba_p,n,m); if(n==m) if(reflexive(ba_p,n,m)) printf("reflexive = yesn"); else printf("reflexive = non"); else printf("reflexive = non"); if(n==m) if(irreflexive(ba_p,n,m)) printf("irreflexive = yesn");
  • 7. else printf("irreflexive = non"); else printf("irreflexive = non"); int u,y,o,e=0; for(u=0; u<n; u++){ for(y=0; y<u; y++){ if(base_arr[u][y] != base_arr[y][u]){ e = 1; break } } } if(e == 1) printf("Symmetric = non"); else printf("Symmetric = yesn"); // getch(); return 0; } int reflexive(int *p,int n,int m){ int i,temp=0,result = 0; for(i=0;i<m;i++){ //printf("%d re %dn",*(p+temp),result); if(*(p+temp) != 1 ) result = 1; temp = temp + n + 1; } if(result == 1) return 0; else return 1; } int irreflexive(int *p,int n,int m){ int i,temp=0,result = 0; for(i=0;i<m;i++){ if(*(p+temp) != 0 ) result = 1; temp = temp + n + 1; //printf("%d re %dn",*(p+temp),result); } if(result == 1) return 0; else return 1; } // // // void arr_prt(int *p ,int n,int m){ int i=0,j=0; while(1){ if(i == n*m) break if(i%m == 0){ printf("n"); j++; } printf("%d ",*p++); i++; }
  • 8. } // // // 변환함수 void Exch(char crr[],int *p){ int nct=0,i=0,n=0,m=0; while(1){ if(crr[i] == '0') break //if(arr[i] == '[') continue; if(crr[i] == ',') n++; if(crr[i] == ']') m++; if(crr[i] == '1'){ *p = 1; p++; } if(crr[i] == '0'){ *p = 0; p++; } i++; } } // // //N x M array sagasuno int Find_n(char arr[]){ int nct=0,i=0; while(1){ if(arr[i] == '0') break //if(arr[i] == '[') continue; if(arr[i] == ']') nct++; i++; } return nct-1; } int Find_m(char arr[]){ int nct=0,i=0; while(1){ if(arr[i] == '0') break //if(arr[i] == '[') continue; if(arr[i] == ',') nct++; if(arr[i] == ']') break i++; } return nct+1; }
  • 9. ※ 과제를 마치면서. - 이번 프로젝트를 하면서 학습내용과 과제를 공부하면서 데이터베이스 시스템에 대하여 이항관계가 어떻게 사용되고 table, tuple과의 상관관계 relational을 이용한 Selection, Projection, join 등을 만드는 법을 배웠고 과제 1을 통하여 관계(reflexive, symmetric, transitive)에 대한 알고리즘과 C에 코딩할 때 어떻게 구성하여야 할지를 알 수 있었습니다. 감사합니다.