|
|
 |
|
자료구조 - 순환과 반복
1. 팩토리얼계산
◎순환
#include [iostream]
using namespace std;
int factorial(int n)
{
if(n==1)
return 1;
else
return (n * factorial(n-1));
}
void main()
{
int n;
cout [[ 정수 입력 : ;
cin ]] n;
cout [[ n [[ 팩토리얼 계산 : [[ factorial(n) [[ endl;
}
◎반복
#include [iostream]
using namespace std;
int factorial_iter(int n)
{
int k, v=1;
for.. |
|
|
|
|
|
 |
|
1. 프로그램 소스
합병정렬(링크를 사용하는) : lec4-5, 퀵정렬(순환버전) : lec5-1 사용
CompareMeasure.java
package exercise_2;
public class CompareMeasure {
public void mergeSort(int n){ // 합병정렬 method (lec 4-5)
int arrSize = n ; // 배열의 크기
int arr[] = new int[arrSize+1];
for(int i=1; i[= arrSize; i++)
arr[i] = (int)(java.lang.Math.random()*(n-1)); //테스트 데이.. |
|
|
|
|
|
 |
|
#include[stdio.h]
#include[stdlib.h]
void inputele(int set[],int set2[],int set3[]); //집합의 입력함수 선언
void ascending(int set[],int num); //집합의 오름차순함수 선언
void overlap(int set[],int num);//집합의 중복원소제거함수 선언
void outputele(int set[],int num); //집합의 출력함수 선언
int main()
{
int set[20] = {0}; //set2와 set3의 합,교,차집합등을 구하고 저장되는 공.. |
|
|
|
|
|
 |
|
3-way 외부 합병 정렬
1. 프로젝트 설명
순차파일(binary형태)로 주어지는 데이터 파일(.dat)에서 킷값에 해당 하는 부분을 가지고 정렬을 실행한다.
3-way 외부 합병정렬을 구현하는데, 버퍼의 크기는 버퍼1, 2, 3은 각각 1KBytes이고, 출력에 쓰이는 버퍼(out[])도 1KBytes이다. 출력버퍼가 가득 차면 임시파일(temp1.txt, temp2.txt)에 binary 형태로 Write 하고, 버퍼를 비운 후에 다시 채워가면서 Me.. |
|
|
|
|
|
 |
|
프로그래밍 및 실습
목차
행렬식 계산
C++로 나타낸 행렬식 계산
결과값
고찰
행렬식 계산
-행렬을 어떠한 하나의 실수 값으로 표현한 것
-행렬식의 성질
(1) 행렬식은 오직 정방 행렬에서만 정의된다.
(2) 구성 성분이 하나인 행렬의 행렬식은 그 성분 자체이다.
(3) 행렬식의 값은 하나의 상수 즉, 임의의 실수이다.
(4) n차의 행렬식 |An*n|은 n개의 행과 열의 위치가 서로 다른 성분들의 곱의 합으.. |
|
|
|
|
|
 |
|
2008-061
프로그래밍언어론 과제#1
정보컴퓨터공학전공 부산대학교
2008년 3월 21일
1. 1.5
문제 - Imperative VS Applicative programs
1.1 Imperative Version
1) Source Code
#include [stdio.h]
#include [stdlib.h]
void print(double value){
printf(%.5f
,value)
}
double fib(int n){// [1]
int index
double last1, last2, result
if(n[=2){
return 1
}
last1 =1
last2 =1
for(ind.. |
|
|
|
|
|
 |
|
시스템소프트웨어실험
4장 예제
report
Ex04-02
#include [unistd.h]
#include [sys/types.h]
#include [sys/stat.h]
int main()
{ int filedes;
mode_t oldmask;
oldmask = umask(023);
filedes = open( test.txt ,O_CREAT, 0777);
close(filedes);
}
Ex04-04
#include [stdio.h]
#include [stdlib.h]
#include [unistd.h]
int main()
{
char *filename = test04.txt ;
if ( access(fi.. |
|
|
|
|
|
 |
|
야구게임
/***
created: 2003/12/10
created: 10:12:2003 1:01
filename: C:\My Project\Baseball\main.c
file path: C:\My Project\Baseball
file base: main
file ext:
author:
김대영 janus.k(akmasky@gmail.com)
http://cafe.naver.com/jklab.cafe
purpose: 야구게임
***/
#include [stdio.h]
#include [stdlib.h]
#include [time.h]
#include [assert.h]
// 매크로 선언
#define MAX_TIM.. |
|
|
|
|
|
 |
|
INDEX
1.목적
2.소스코드
3.이용한 함수
4.출력결과
5.정리
1.목적
정수값을 입력한 정수의 개수대로 임의로 받아 큐에 enqueue,dequeue 하여 출력값을 txt 파일에 출력한다. 다시 같은 값을 스택에 push 한 후, 다시 pop 하여 그 값들이 역순으로 txt 파일로 출력되도록 한다.
2.소스코드
헤더파일1 //ArrayBaseStack.h
#ifndef __AB_STACK_H__
#define __AB_STACK_H__
#define TRUE 1
#define FALSE 0.. |
|
|
|
|
|
 |
|
◆ 소스코드 ◆
/* 연결스택과 큐 프로그램. 32051492 정국형. jgh815@live.co.kr */
#include[stdio.h]
int pushstack(); //스택에 데이터를 입력하는 함수
void stacklink(struct stack *data); // 데이터를 스택 링크 리스트로 이어주는 함수
void stackprint(); //스택의 내용을 보여주는 함수
void deletestack(); //스택의 데이터를 삭제 하는 함수
void pushqueue(); //큐에 데이터를 입력하는 함수
.. |
|
|
|
|
|
 |
|
포인터정의!
포인터와배열
포인터와함수
Const static
포인터!
다른 변수의 주소를 값으로 가지는 변수
포인터 변수
-] 변수에 저장되는 값이 메모리의 주소값만을 저 장 하는 특별한 변수
포인터 변수
-] *기호로 선언
*(에스크립터)의 뜻은 세가지
곱하기
포인터 변수 선언할 때
포인터 변수가 가리키는 변수의 실제 값을 구할 때
포인터변수
포인터변수2
1.주소 연산자 (ampersand)
-] 변수의 주소 .. |
|
|
|
|
|
 |
|
실험․실습 보고서
함수 그리고 전역변수와 지역변수, 정적변수
1. 제목
함수 그리고 전역변수와 지역변수, 정적변수
2. 목적
전역변수와 지역변수, 정적변수들을 함수의 특성에 맞게 적재적시에 구현 할수 있게 한다.
3. 실습에 필요한 기초지식
4. 실습 절차, 내용 및 결과
(1) 지역변수
#include [stdio.h]
void f1( int a);// 함수 선언
void main()
{
int a= 10; // 지역 변수 -{} 내에서 사.. |
|
|
|
|
|
 |
|
1. Linked list를 사용하여, Queue의 모든 연산을 구현하시오.
Str_queue.h
// 구조체선언
struct node
{
int data; // 이름 메일 전화번호 선언
node *next;// 다음 노드의 주소를 가르킴
};
class queueClass{
public:
queueClass(); //생성자함수
queueClass(const queueClass s); //복사생성자함수
~queueClass(); //소멸자함수
void add(int Item); //Item 값을 큐에 삽입
void remove(); //큐.. |
|
|
|
|
|
 |
|
- source program(loader.c)
#include
#include
#include
#include
#include
#define M 30
typedef struct estab *estab_ptr;
typedef struct estab{
char name[7];
unsigned addr;
estab_ptr link;
}estab;
estab_ptr table[20];
void pass1(char *[]);
int errchk(char *);
void insert(char *, unsigned);
unsigned hash(char *);
void prn.. |
|
|
|
|
|
 |
|
ARRIVAL 1 2 3 경우
TIMEOUT 2 의 경우 Sn의 경우 요청이올경우마다 1씩 커짐
ACK 3의 경우
// s size는 2의 3승으로 m=4 크기는 8일경우를 구현한것입니다
#include [iostream]
using namespace std;
void main()
{
char a[20];
int x,y,z;
.... |
|
|
|
|
|