Week 6: Linear Lists - Simulated Pointer Representation
6주차 선형 목록 : 포인터 시뮬레이트 표현법.
Since we have midterm exams next week, I will give you an extremely easy assignment. I belive that this takes only a couple of hours.
다음주에 시험이니까 매우쉬운 과제를 줄께, 난 이 과제가 2시간 정도 걸릴거라고 생각해.

Section 7.7 introduces the concepts of the equivalent relationship and union set.
7.7장에서 동등관계와 공용체의 컨셉을 소개했다.

Just type in the example code to find the union set, and write a program that test the example code.
책에서 공용체를 찾는 코드를 그대로 쳐라, 그리고 그것을 테스트하는 예제 코드를 만들어 보아라.

What you will turn in is a PDF file that contains the test code, screen shots of the test program in execution, and brief explanation of your understanding on the concepts of the equivalent relationship and union set.
니가 할일은 테스트 코드와, 실행 스크린샷, 그리고 니가 이 컨셉을 이해했다는것을 증명하는 설명을 PDF에 담아 제출하는것이다.

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Week 7: Array and Matrices  (0) 2010.05.03
Data Structure 6번째 HW  (0) 2010.04.15
Data Structure 5번째 HW(내맘대로 분석)  (0) 2010.04.10
Data Structure 5번째 HW(번역)  (0) 2010.04.10
Data Structure 5번째 HW  (0) 2010.04.10

Week 6: Linear Lists - Simulated Pointer Representation

Since we have midterm exams next week, I will give you an extremely easy assignment. I belive that this takes only a couple of hours.

Section 7.7 introduces the concepts of the equivalent relationship and union set. Just type in the example code to find the union set, and write a program that test the example code. What you will turn in is a PDF file that contains the test code, screen shots of the test program in execution, and brief explanation of your understanding on the concepts of the equivalent relationship and union set.

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Week 7: Array and Matrices  (0) 2010.05.03
Data Structure 6번째 HW(번역)  (0) 2010.04.15
Data Structure 5번째 HW(내맘대로 분석)  (0) 2010.04.10
Data Structure 5번째 HW(번역)  (0) 2010.04.10
Data Structure 5번째 HW  (0) 2010.04.10

Week 5: Linear Lists - Linked Representation

1. Write code for the class ChainWithSortMethods.

ChainWithSortMethods 클래스를 만들어라


This class is a subclass of Chain and it includes the number method insertionSort, which uses insertion sort to reorder the chain elements into nondecreasing order.
이 클래스는 Chain을 상속받는다. 그리고 인자의 크기를 오름차순 정렬하는 insertionSort 메소드를 갖고있다.

=========================================================

위 두가지의 조건에 맞추려면 Chain은 그냥 저자 홈페이지에서 갖고오고, 나머지는 그냥 쓰면 되겠다.


Do not create new nodes or delete old ones.

노드를 새로 생성하거나 삭제하지 마라.


=========================================================

헐,,, 이건 좀 문제다,,,,, 링크만 수정하는 방식으로 가야겠네,,,


a) What is the worst-case time complexity of your method? How much time does your method need if the elements are already in sorted order?

최악의 경우 에 시간복잡도는 얼마인가?

이미 정리되어 있는 경우에는 시간이 얼마나 걸리는가?


b) Test the correctness of your method by compiling and then executing the code. Use your own test data (any programs with any data are allowed).

측정의 정확성을 위해 컴파일링을 하고 실행해봐라.

너만의 테스트 데이터를 만들어라

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Data Structure 6번째 HW(번역)  (0) 2010.04.15
Data Structure 6번째 HW  (0) 2010.04.15
Data Structure 5번째 HW(번역)  (0) 2010.04.10
Data Structure 5번째 HW  (0) 2010.04.10
Data Structure 4번째 HW(번역)  (0) 2010.04.01

Week 5: Linear Lists - Linked Representation

1. Write code for the class ChainWithSortMethods.

ChainWithSortMethods 클래스를 만들어라


This class is a subclass of Chain and it includes the number method insertionSort, which uses insertion sort to reorder the chain elements into nondecreasing order.
이 클래스는 Chain을 상속받는다. 그리고 인자의 크기를 오름차순 정렬하는 insertionSort 메소드를 갖고있다.
Do not create new nodes or delete old ones.

노드를 새로 생성하거나 삭제하지 마라.


a) What is the worst-case time complexity of your method? How much time does your method need if the elements are already in sorted order?

최악의 경우 에 시간복잡도는 얼마인가?

이미 정리되어 있는 경우에는 시간이 얼마나 걸리는가?


b) Test the correctness of your method by compiling and then executing the code. Use your own test data (any programs with any data are allowed).

측정의 정확성을 위해 컴파일링을 하고 실행해봐라.

너만의 테스트 데이터를 만들어라

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Data Structure 6번째 HW  (0) 2010.04.15
Data Structure 5번째 HW(내맘대로 분석)  (0) 2010.04.10
Data Structure 5번째 HW  (0) 2010.04.10
Data Structure 4번째 HW(번역)  (0) 2010.04.01
Data Structure 4번째 HW  (0) 2010.04.01

Week 5: Linear Lists - Linked Representation

1. Write code for the class ChainWithSortMethods. This class is a subclass of Chain and it includes the number method insertionSort, which uses insertion sort to reorder the chain elements into nondecreasing order. Do not create new nodes or delete old ones.


a) What is the worst-case time complexity of your method? How much time does your method need if the elements are already in sorted order?


b) Test the correctness of your method by compiling and then executing the code. Use your own test data (any programs with any data are allowed).

1. Make an interface “StudentLinearList” as shown in Program 5.1.
프로그램 5.1 에 있는것과 같이 StucentLinearList 인터페이스를 만들어라.

Implement the “StudentArrayLinearList” class, which is an implementation of the interface “StudentLinearList”.
StudentLinearList를 인터페이스로 갖는, StucentArrayLinearList클래스를 구현하여라.

Modify the time measuring program, which was used in the last homework, by replacing the “Student” object array with the “StudentArrayList” class.
지난번 과제에서 만들어 놓은 시간측정프로그램을 Student배열을 사용하던것에서 StudentArrayList클래스를 사용하는것으로 수정해라.

2. Extend “StudentArrayLinearList” to include the method “removeRange”, which removes all elements in the specified index range.
StudentArrayLinearList를 특정 인덱스 범위를 제거하는 removeRange메소드를 갖도록 확장해라.

What is the complexity of your method?
이 메소드의 복잡도는 얼마인가?

3. Extend “StudentArrayLinearList” to include the method “concateList”, which concatenates a parameter “StudentArrayLinearList” to the list of the method-owner object.
StudentArrayLinearList를 StudentArrayLinearList를 인자로 하여, 원래 배열에 인자로 받은 배열을 이어 붙이는 concateList메소드를 갖도록 확장해라.

What is the complexity of your method? Test your code with a simple example code.

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Data Structure 5번째 HW(번역)  (0) 2010.04.10
Data Structure 5번째 HW  (0) 2010.04.10
Data Structure 4번째 HW  (0) 2010.04.01
Data Structure 3번째 HW(번역)  (0) 2010.03.27
Data Structure 3번째 HW  (0) 2010.03.27
1. Make an interface “StudentLinearList” as shown in Program 5.1. Implement the “StudentArrayLinearList” class, which is an implementation of the interface “StudentLinearList”. Modify the time measuring program, which was used in the last homework, by replacing the “Student” object array with the “StudentArrayList” class.

2. Extend “StudentArrayLinearList” to include the method “removeRange”, which removes all elements in the specified index range. What is the complexity of your method?

3. Extend “StudentArrayLinearList” to include the method “concateList”, which concatenates a parameter “StudentArrayLinearList” to the list of the method-owner object. What is the complexity of your method? Test your code with a simple example code.

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Data Structure 5번째 HW  (0) 2010.04.10
Data Structure 4번째 HW(번역)  (0) 2010.04.01
Data Structure 3번째 HW(번역)  (0) 2010.03.27
Data Structure 3번째 HW  (0) 2010.03.27
Data Structure 2번째 HW(내맘대로 분석 #2)  (0) 2010.03.20
1. Now we have four sorting algorithm implementations, which were originated from the 2nd week homework.
이제 우리는 2번째 과제의 4개의 정렬 알고리즘을 갖고있다.
This is the time for asymptotically analyze each program. Of course, you have to analyze them under best, worst and average cases.
이번엔 점근적인(asymptotically) 분석을 해보자. 물논, 최악, 최적, 평균적인 사건에 대해 분석해야 된다.

2. Since we have the actual implementations, we can measure the execution time of them.
실제로 구현을 해놓았기 때문에 우리는 각 알고리즘의 실행시간을 측정할수 있다.

As we learned in the class, insert profiling (time measuring) code into your programs, and measure the time to sort randomly generated data sets (Yes, you have to make random student object generating code, too!).
우리가 수업에서 배운 시간 측정용 코드를 너의 프로그램에 넣어라, 그리고 임의로 생성된 데이터셋을 정렬하는 시간을 측정하여라(우리는 랜덤한 학생 오브젝트를 만드는것도 수업시간에 해 보았다.)

The number of students to be sorted must vary from 10 to 1,000,000 by log-scale increment (10, 100, 1,000, 10,000, … on and on).
학생의 숫자는 10에서 1,000,000 까지 큼직큼직하게 변해야 한다(10, 100, 1,000, 10,000, 이런식으로,,)

Draw graphs illustrating the tendency of the execution time changes depending on the changes of the data set size.
데이터 셋의 사이즈에 따라 실행 시간이 변하는 추세를 나타내는 그래프를 그려라.

The source codes, analysis results and graphs have to be prepared in a PDF file.
소스코드와, 분석결과, 그리고 그래프는 반드시 PDF파일로 보내세요.
1. Now we have four sorting algorithm implementations, which were originated from the 2nd week homework. This is the time for asymptotically analyze each program. Of course, you have to analyze them under best, worst and average cases.

2. Since we have the actual implementations, we can measure the execution time of them. As we learned in the class, insert profiling (time measuring) code into your programs, and measure the time to sort randomly generated data sets (Yes, you have to make random student object generating code, too!). The number of students to be sorted must vary from 10 to 1,000,000 by log-scale increment (10, 100, 1,000, 10,000, … on and on). Draw graphs illustrating the tendency of the execution time changes depending on the changes of the data set size.

The source codes, analysis results and graphs have to be prepared in a PDF file.
===================================================================================================
RankSort 분석
===================================================================================================





'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Data Structure 3번째 HW(번역)  (0) 2010.03.27
Data Structure 3번째 HW  (0) 2010.03.27
Data Structure 2번째 HW(내맘대로 분석)  (0) 2010.03.18
Data Structure 2번째 HW(번역)  (0) 2010.03.18
Data Structure 2번째 HW  (0) 2010.03.18
===================================================================================================
문제 분석
===================================================================================================

음,, 일단 랭크소트가 무엇인지를 파악해야겠군,,,
최형이라면 알지도 모르지만, 혼자 해보는것도 재미있을것 같다,,
문제는 시간.

시간 복잡도의 경우도 “counting the comparison operations(비교 연산자 갯수 세기)”는 쉬운데 “counting the steps with the s/e and frequency table(스텝을 세어서 빈도분석)”법은,,,,, 서의성 교수님 시간이었지만, 전날 무리하는 바람에 못들었다..

공부할게 많네,,,

공간 사용에 대해서는 보통 정렬의 경우에 공간은 거의 차지하지 않지, 임시공간 1개 정도? (merge의 경우를 제외하면,, 저번에 보니까 merge도 새로 안만들고 어떻게 하는 모양이던데,, 나는 같은 크기의 배열을 2개 만들고 옮겨 다녔으니,,,,)

 뭐,,, 오늘부터 해봐야지..

'생활 > 데이터 스트럭쳐' 카테고리의 다른 글

Data Structure 3번째 HW(번역)  (0) 2010.03.27
Data Structure 3번째 HW  (0) 2010.03.27
Data Structure 2번째 HW(내맘대로 분석 #2)  (0) 2010.03.20
Data Structure 2번째 HW(번역)  (0) 2010.03.18
Data Structure 2번째 HW  (0) 2010.03.18
===================================================================================================
번역
===================================================================================================
1. Our textbook introduces another sorting algorithm called rank sort at page 80.
1. 우리의 교제에서는 또다른 정령 알고리즘인 rank정렬을 80페이지에서 소개하고 있다.
Make a rank sort program that sorts students by their name and print their scores along side the names in the sorted order.
Rank정렬을 이용하여 학생들을 그들의 이름으로 정렬하고, 그들의 점수를 정렬된 이름옆에 표시하는 프로그램을 작성하여라.
Student names and scores must be included in a Student object.
학생의 이름과 점수는 반드시 Student 오브젝트에 포함되도록 만들어져야 한다.
The data are input through keyboard and the number of students is flexible (use a sentinel).
입력받는 데이터는 키보드로 입력받도록 하고, 학생의 수는 자유롭게 입력 받을수 있도록 한다(sentinel은 보초라는 뜻인데,,,,).
Analyze the best case, worst case and average case space and time complexity of the program you made.
당신이 만든 프로그램에서 시,공간 복잡도를 최적, 최악, 평균적인 경우을 놓고 분석하여라.
For time complexity, use both “counting the comparison operations” and “counting the steps with the s/e and frequency table” approaches.
시간 복잡도의 경우 “counting the comparison operations(비교 연산자 갯수 세기)”와 “counting the steps with the s/e and frequency table(스텝을 세어서 빈도분석)”법을 모두 사용하여라.

2. Modify the program for problem 1 by replacing the sorting algorithm with bubble sort, insert sort and selection sort.
2. 1에서 만들었던 프로그램을 Bubble정렬과 Insert정렬, Selection정렬로 고쳐보아라.
Also, you have to analyze the best, worst and average case space and time complexity of each version.
또한 최적, 최악, 평균적인 경우의 시, 공간 복잡도를 각각 분석하여라.

* The source codes, analysis results and screen shots of your programs in working have to be prepared in a PDF file.
* 소스코드와 분석결과, 그리고 프로그램 작동의 스샷은 PDF파일로 작성하여라.

1. Our textbook introduces another sorting algorithm called rank sort at page 80. Make a rank sort program that sorts students by their name and print their scores along side the names in the sorted order. Student names and scores must be included in a Student object. The data are input through keyboard and the number of students is flexible (use a sentinel). Analyze the best case, worst case and average case space and time complexity of the program you made. For time complexity, use both “counting the comparison operations” and “counting the steps with the s/e and frequency table” approaches.

2. Modify the program for problem 1 by replacing the sorting algorithm with bubble sort, insert sort and selection sort. Also, you have to analyze the best, worst and average case space and time complexity of each version.

* The source codes, analysis results and screen shots of your programs in working have to be prepared in a PDF file.

드디어 서버 설치가 완료됬어요!

'대학생활 > 동아리' 카테고리의 다른 글

동아리 서버설치(3)  (0) 2009.11.19
동아리 서버설치(2)  (0) 2009.11.19
동아리 서버설치(1)  (0) 2009.11.19
01234567891011

자 너무 많아서 Gallery로 묶었습니다. 웹 플랫폼 빌더로 한번에 웹서버 설치중...

어느새 모여든 회원들,,,

모종의 오류로 플랫폼빌더 재실행,,,

다시 설치해서 텍스트 큐브 설정,,,

드디어 나타난 텍큐 설치화면(위에서 설정 다했는데 왜 또 나오는거지??)

이렇게 삽질을 거듭한 끝에 만들었는데, 결론은 하이퍼-V를 설치하다가 좆ㅋ망ㅋ,,,
지금 기숙사에서 다시 윈도 밀고 재작업 중입니다..ㅠㅠ

'대학생활 > 동아리' 카테고리의 다른 글

드디어 서버 설치 완료!!  (0) 2009.11.20
동아리 서버설치(2)  (0) 2009.11.19
동아리 서버설치(1)  (0) 2009.11.19

자, 이래저래 라이센스도 읽고 이제 설치를 시작했습니다.


자 정품인증을 하고 있습니다.(정품 맞습니다. 마이크로소프트 드림스팍에서 학생들 공부용으로 준거니, 동아리 활동에 쓰는건 라이센스 위반 아니겠죠?)


자 정품 인증샷!!

'대학생활 > 동아리' 카테고리의 다른 글

드디어 서버 설치 완료!!  (0) 2009.11.20
동아리 서버설치(3)  (0) 2009.11.19
동아리 서버설치(1)  (0) 2009.11.19
오늘은 동아리의 서버를 설치했습니다
서버의 OS는 윈도우 서버 2008 R2 스텐다드 버전이고,
서버의 종류는 IIS+PHP+MYSQL 이에요.

설치파일이 다 올라오기를 기다리는중,,,(실수로 접사를 안빼놓고 찍어서 글자가 뭉개졌,,,)

왜인지는 모르겠지만 설치파일이 안올라 와서 그동안 동아리 세미나 홍보용 간판제작(날짜를 빼먹어서 다시만들,,,,쿨럭)

드디어 버전선택 화면. 여러가지 있는데 그냥 2008 R2 스텐다드로 설치~

'대학생활 > 동아리' 카테고리의 다른 글

드디어 서버 설치 완료!!  (0) 2009.11.20
동아리 서버설치(3)  (0) 2009.11.19
동아리 서버설치(2)  (0) 2009.11.19

template <typename T>

void BubbleSort2(T arr[], const int size)

{

bool Sorted = true;

for (int i=size; i>0 && Sorted; i--)

{

Sorted = false;

for (int j=0; j<i; j++)

{

if (arr[j] < arr[j-1]) {

T t=arr[j];
arr[j]=arr[j-1];
arr[j-1]=t;

Sorted = true;

}

}

}

}


약간의 트릭을 더해서 만든 정렬이다.

정렬을 한뒤에는 true를 만들어서 그 j에 대해서는 더이성 정렬을 안한다.

정렬이 거의 된 배열에서는 일반 버블보다 월등히 빠른 속도를 보이며,

임의 배열에서는 많은 속도의 향상이 있고

역순배열에서도 약간 속도 향상이 있었다.


'생활 > 알고리즘(?)' 카테고리의 다른 글

버블정렬  (0) 2009.11.15
엊그제 배송된 페도라 리눅스 책을 보면서 페도라 11을 2대 설치했다.
0

근데 문제는 책에는 페도라 코어 4로 설명이 되있고, 부록으로 설치시디 4장이 들어있다.
하지만 내 책에는 부록으로 시디가 2장밖에 없었다!!!

받자마자 설치파트를 보고 다운받으러 갔다가 페도라 11로 업그레이드 된걸 보고,
처음은 시키는 대로 해야지 라는 생각에 설치시디를 보니 1/4, 2/4만 있고, 3/4, 4/4가 없었다.

혹시 1, 2만 갖고 데모를 써본뒤에 3,4는 알아서 구하라는건가? 싶어 yesXX서점에
바로 문의를 해보고 받은 답변,,
0

일단 페도라 11로 갖고 놀고 있어야지,,, 근데 몇가지 명령어(? 프로그램? )이 빠진건지 사라진건지,,,
코어4는 지원기간도 끝났고,,

P.S. 코어가 무료배포용이라고 했는데, 페도라로 다시 합쳐진건기???

'생활 > 공부' 카테고리의 다른 글

구성 요소 기본 포트 번호  (0) 2009.12.30
10만원어치 책,,,  (0) 2009.11.12
10만원어치 책,,, 생활/공부 2009. 11. 12. 20:58

오늘은 yes**.com에서 주문한 10만원어치 책이 도착했다.
리눅스 서버관리관련 책과, 리눅스 프로그래밍 책을 주문했는데 2일만에 왔으니 빠른편.
012
이 범상치 않은 크기를 보라,,,( 우리방의 임시 쓰레기통이 될듯됨)

개봉샷

012
첫장은 무시,,,,,,,, 역시 큰상자에는 큰 책들이,,,

012
제일 뚜꺼운 실무 바이블책,,, 심지어 상,하 2권,,ㄷㄷ

01

자자 딴건보지말고 컴퓨터책만 98000원,,, 나이거 언제 다보지?

01

다시한번 이 웅장한 뚜께,,(두께가 아님!!)

일주일 만에 완파하고 UPC의 서버를 만들어주마!!

'생활 > 공부' 카테고리의 다른 글

구성 요소 기본 포트 번호  (0) 2009.12.30
호랭이 두마리 입양 완료!!  (0) 2009.11.14

저번에는 클래스에 대해서 대략 개요만 짚고 넘어갔어,,
이번에는 실제 클래스의 용례를 알려줄께

#include <iostream>

using namespace std;

class Calculator
{
private:
       double result;                           //결과를 저장할 변수
public:
       Calculator();                             //생성자
       Calculator(double a);                //오버로딩된 생성자
       double addnum(double a);        //덧셈
       double subnum(double a);        //뺄셈
       double mulnum(double a);        //곱셈
       double divnum(double a);          //나눗셈
       double modnum(double a);        //나머지
       double getresult();                     //결과
};

int main()
{
        Calculator c(3.14);
        cout << c.getresult() << endl;

        cout << c.addnum(2.8) << endl;
        cout << c.getresult() << endl;

        cout << c.subnum(1.8) << endl;
        cout << c.getresult() << endl;

        cout << c.mulnum(2.3) << endl;
        cout << c.getresult() << endl;

        cout << c.divnum(2.8) << endl;
        cout << c.getresult() << endl;

        cout << c.modnum(3) << endl;
        cout << c.getresult() << endl;
        
        return 0;
}

Calculator::Calculator()                             //생성자
{
           result=0;
}
Calculator::Calculator(double a)                //오버로딩된 생성자
{
           result=a;
}
Calculator::double addnum(double a)        //덧셈
{
           result+=a;
           return result;
}
Calculator::double subnum(double a)        //뺄셈
{
           result-=a;
           return result;
}
Calculator::double mulnum(double a)        //곱셈
{
           result*=a;
           return result;
}
Calculator::double divnum(double a)          //나눗셈
{
           result/=a;
           return result;
}
Calculator::double modnum(double a)        //나머지
{
           result%=a;
           return result;
}
Calculator::double getresult()                     //결과
{
           return result;
}

간단한 계산 클래스를 만들었어,
순식간에 만들어서 오타가 있을지도 모르니 오타지적은 환영^^
일단 지금까지의 강좌를 잘 읽었다면 어렵진 않은 소스라고 생각해.
우선 맨 처음의

class Calculator

부분은 클래스를 생성하겟다는 선언부분
그 밑의
{
}
는 클래스의 몸통이 되는거지.
그다음
private:
라는것이 있는데,
여기서 ; 가 아니라 : 라는거 주의해야되.
이거는 이 밑으로 나오는것은 클래스 내부의 숨겨진(캡슐화된) 사항이니까,
외부의 참조나 호출은 금지된다는 표시야. 이 밑으로 나오는것은 c.뭐시기 로 호출이 불가능해.

그 다음 변수선언 하고,
public:
이 있는데 이거는 private랑은 반대로,
이 밑의 것들은 외부의 접근을 허용한다. 라는 표지야.
이게 없으면 class를 만들어도 소용이 없지뭐,,,
사용할것들이 없으니,,,

그다음 main함수에 들어와서 처음나오는거
Calculator c(3.14);
이거는 Calculator클래스의 object인 c를 생성하면서, 생성자 Calculator(double a)를 호출하라는거. 생성자는 좀있다가 설명할께.

그다음은 이제 만들어놓은 갖가지 메소드를 사용해보고,,,

그밑에 Calculator:: 하고 시작하는것들 있지? 이게 메소드의 몸통을 선언하는거야.
위에서 class선언때는 프로토 타입만 선언해놨잖아? 그럼 몸통을 정의 해야지.
근데 여러클래스를 한 프로그램에서 사용한다면 같은이름의 함수를 여러 클래스에서 쓸수도 있잖아? 그래서 컴파일러가 어떤함수가 어떤 클래스껀지 알수있도록 클래스이름을 써주는거야.
그다음은 함수선언과 똑같은데, 처음에 반환형에 아무것도 안써주고, 이름이 class이름이랑 같은놈이 2개 있지? 이게 생성자야.
생성자는 object가 생성될때 호출되는 함수인데, 여기서는 일반적으로 맴버변수들의 초기화등을 담당하도록 해.
하나는 생성할때 인자가 없이 Calculator a; 식으로 선언할때 호출되는거도 다른 하나는 Calculator a(1.23); 식으로 선언될때 호출되는거야. C++은 같은이름의 함수라도 인자의 종류와 갯수가 다르다면 다른 함수로 인식하기 때문에 써먹을수 있는 방법이지.
오늘은 클래스와 생성자까지 했어. 아직은 포인터에대해 배우지 않았고, 동적인 할당과 정적인 할당, 그에앞서 배열도 안배웠으니,,, 소멸자는 나중으로 넘겨놓을께,, 여기까지 모르는거는
nateon : dcmichael@nate.com
msn : dcmichael@live.co.kr
H.P. : 010-2885-4585
또는 블로그의 댓글
로 연락하면 언제든지 답변해줄테니까 당장 숙제에 관한것말 알려달라고만 하지말고 C++을 제대로 공부해보자!!

'대학생활 > C++' 카테고리의 다른 글

C++숙제,,,  (0) 2009.04.09
4주차 C++숙제가 떳습니다.  (0) 2009.04.01
3주차 C++숙제가 나왔습니다!!  (0) 2009.03.23
내맘대로 강좌 C++편 6 (함수편)  (5) 2009.03.23
내맘대로 강좌 C++편 5  (2) 2009.03.19


일단 사회시간 쪽지시험보듯 빈칸채우기 문제가 있습니다.
뭐,, 간단한 것들이지만, C++을 한글로 공부했고 문제가 한글이었으면,
쉬웠을 문제지만, 문제가 영어이다보니, 한글로 공부했을때랑 어휘때문에,
해석에 애로가 꽃피더군요,,ㄷㄷ

다음은 간단한 질문(ex>string에서 두 문자열을 더하는 연산자는? 이라던가, 서로 같지 않음을 판별하는 논리연산자는 무엇인가? 같은)이 있고,

그다음 소스의 빈칸채우기,, 이거는 기존 숙제로 내주신 문제가 거의 그대로 나왔으니,, 숙제를 다시한번 점검해보세요,

마지막 하이라이트는 함수 만들기, 간단한 작업을 하는 함수(C++은 팩토리얼 함수를 구현하라더군요,,)를 직접 코딩해야됬습니다.

자바랑 C++은 담당 교수님이 같은분이니,, 같은 유형의 문제가 나올 확률이 높네요,, 자바 공부하시는 님들께 참조가 됬으면 좋겠습니다..

그리고 항상 궁금한거 있으시면 서의성 교수님이나 저에게 물어보면 친절히 답해드립니다.
H.P 010-2885-4585
nateon : dcmichael@nate.com
msn : dcmichael@live.co.kr

http://dcmichael.tistory.com/28  << 여기에서 확인해 주세요

'생활 > 프로그래밍' 카테고리의 다른 글

간단한 DLL다운로더!  (0) 2009.08.07
에러 잡았다!!!  (0) 2009.08.07
sdl로 ttt만드는중!!  (1) 2009.04.26
리버시(오델로) 프로그래밍 도와주세요!!  (0) 2009.03.19
오델로 게임 1.0.0.0버전  (6) 2009.03.19
C++숙제,,, 대학생활/C++ 2009. 4. 9. 17:56

이제 C++패스했다고, 점점 귀찮아 집니다....ㄷㄷ

1. Julian dates. Suppose you would like to know how many days ago Columbus was born. It is tedious to figure this out by hand, because months have different lengths and because you have to worry about leap years. Many people, such as astronomers, who deal with dates a lot have become tired of dealing with the craziness of the calendar and instead represent days in a completely different way: the so-called Julian day number. That value is defined as the number of days that have elapsed since Jan. 1, 4713 B.C. A convenient reference point is that October 9, 1995, is Julian day 2,450,000.

Here is an algorithm to compute the Julian day number: Set jd, jm, jy to the day, month, and year. If the year is negative, add 1 to jy. (There was no year 0. Year 1 B.C. was immediately followed by year A.D. 1) If the month is larger than February, add 1 to jm. Otherwise, add 13 to jm and subtract 1 from jy. Then compute

long jul = floor(365.25 * jy) + floor(30.6001 * jm) + d + 1720995.0

We store the result in a variable of type long; simple integers may not have enough digits to hold the value. If the date was before October 15, 1582, return this value. Otherwise, perform the following correction:

int ja = 0.01 * jy;

jul = jul + 2 - ja + 0.25 * ja;

Now write a function

long julian(int year, int month, int day)

that converts a date into a Julian day number. Use that function in a program that prompts the user for a date in the past, then prints out how many days that is away from today's date.

이게 1번문제 이고

 

2. Write a procedure void sort2(int& a, int& b) that swaps the values of a and b if a is greater than b and otherwise leaves a and b unchanged. For example,

int u = 2;

int v = 3;

int w = 4;

int x = 1;

sort2(u, v);

/* u is still 2, v is still 3 */

sort2(w, x);

/* w is now 1, x is now 4 */
이게 2번인데,,,
1번은 무슨 juliandate라는 만년력을 구하라는 문제 같고,,
2번은 간단히 크기가 작은것을 앞으로 큰것을 뒤로 보내는 문제 같네여,, C++은 BB를 보시면 교수님의 ppt도 있고, wiley에 보시면 교재도 있으니,, 참조변수에 관한것을 좀 보시는것이 도움이 되겠네요,,

JAVA숙제,,, 대학생활/JAVA 2009. 4. 9. 17:36

요즘 정신없이 사느라 티스토리도 못들어 오네요,,,ㄷㄷ
일단 이번숙제는

1. Write a unit conversion program that asks users to identify the unit from which they want to convert and the unit to which they want to convert. Available units should be mm, cm, m, ft, and in. Define two objects of a class UnitConverter that convert between meters and a given unit.
Convert from:
in
Convert to:
mm
Value:
10
10 in = 254 mm
Use the following class as your main class:
import java.util.Scanner;

/**
   This class converts between two units.
*/
public class ConversionCalculator
{
   public static void main(String[] args)
   {
      Scanner in = new Scanner(System.in);

      System.out.println("Convert from:");
      String fromUnit = in.nextLine();

      System.out.println("Convert to:");
      String toUnit = in.nextLine();

      UnitConverter from = new UnitConverter(fromUnit);
      UnitConverter to = new UnitConverter(toUnit);

      System.out.println("Value:") ;
      double val = in.nextDouble();

      double meters = from.toMeters(val);
      double converted = to.fromMeters(meters);

      System.out.println(val+ " "+ fromUnit+ " = "+ converted
            + " "+ toUnit);
   }
}


이거입니다.
mm, cm, m, ft, in중 2개를 선택받아 서로 단위를 변환하는 계산기 문제인데요,,
UnitConverter 란 클래스를 만들어서
생성자에서는 처음 들어간 string을 갖고 처음의 단위를 계산하고, toMeter라는 함수를 이용해서 공통단위인 Meter로 고침니다. 그다음 그Meter단위 숫자를 받아서 다시 원하는 단위로 고치는,,,


순서는 이렇습니다.

1. 먼저 2개의 단위를 입력받습니다.
2.  이것을 각각 from, to라는 UnitConverter클래스에 생성자의 인자로 주어 from, to의 단위를 정합니다.
3. 그다음 from을 meter로 바꾸는 함수를 이용해 meter값을 임시변수에 넣습니다.
4. meter단위인 임시변수를 to 에 집어넣어 to 단위로 바꿈니다.
5. 이것을 출력합니다.,,,

말은 쉽지만, 이걸 하려면 if노가다나 단위변환상수를 정해놔야겠군요,,,

'대학생활 > JAVA' 카테고리의 다른 글

Eclipse 단축키  (0) 2010.03.21
내맘대로 강좌 JAVA편,,,ㅠㅠ  (2) 2009.04.23
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
늦었지만 공지 합니다.
제가 C++을 패스하고 좀 게을러 졌네요,,,

1번.
"Do you want to continue?"라는 문구를 출력한뒤 사용자게  "Y", "Yes", "OK", "Sure", or "Why not?"을 입력하면 "OK"를 출력하고, "N", "No"를 입력하면 "Terminating"을 출력,
둘다 아니면 "Bad input"을 출력하도록 하고, 대소문자는 구분하지 않는대요,,

2번.
계속 사용하던 Employee 클래스형 변수를 이용해서 이름과 시급을 읽어 냅니다.
그후 일주일에 몇시간을 일했는지를 물어보고, 1주일의 급여를 계산하는데,
주당 40시간 이상 일한부분은 1.5배의 봉금을 주래요,,, (맞나, 오역이 있으면 댓글이나 쪽지로,,)

문제는 이 두가지 인데,
1번은 입력을 받은뒤 if문을 쓸줄 아느냐? 라는 문제이고,
2번은,, 글쎄,, 값을 갖고,,,, 이것도 if문이네요,,
열심히 해 보세요(참 쉽죠?)

그리고 제가 모든것을 다 설명드릴수는 없지만(검열때문에), dcmichael@nate.com <<네이트온
으로 쪽지주시면 모르는 부분은 좀더 자세히 설명해 드리겠습니다

'대학생활 > C++' 카테고리의 다른 글

내맘대로 강좌 C++편 7 (클래스)  (1) 2009.04.23
C++숙제,,,  (0) 2009.04.09
3주차 C++숙제가 나왔습니다!!  (0) 2009.03.23
내맘대로 강좌 C++편 6 (함수편)  (5) 2009.03.23
내맘대로 강좌 C++편 5  (2) 2009.03.19
너무 늦었지만, 공지합니다.
이번 숙제는 두개의 수를 입력받을수 있고
합, 차, 곱, 평균, 차이의 절대값, 둘중 큰수, 둘중 작은수
들을 출력할수 있는 클래스 Pair을 설계하는것 이 첫번째 숙제고요,

두번째는 DataSet 라는 클래스를 설계해서 값을 입력받고, 입력받은값중
제일 큰 수와 제일 작은수를 출력하는 클래스를 설계하랍니다.

우선 첫번째 Pair클래스는
 public class Pair
{
   /**
      Constructs a pair.
      @param aFirst the first value of the pair
      @param aSecond the second value of the pair
   */
   public Pair(double aFirst, double aSecond) { . . . }

   /**
      Computes the sum of the values of this pair.
      @return the sum of the first and second values
   */
   public double getSum() { . . . }
   . . .
}
이런식이 되야겠구요,
두번째 DataSet 클래스문제는 초기화땐 Integer.MIN_VALUE, Integer.MAX_VALUE 라는 함수를 사용하고, 대소를 구분할땐 Math.max, Math.min함수를 사용하라는 힌트가 주어졌군요,,, if 같은거 쓰지 말래요,,,
그리고 각각 Pair클래스를 테스트하는 PairTester클래스와
DataSet클래스를 테스트하는 DataSetTest클래스도 만들어야 겠네요,,

제가 모든것을 다 설명드릴수는 없지만(검열때문에), dcmichael@nate.com <<네이트온
으로 쪽지주시면 모르는 부분은 좀더 자세히 설명해 드리겠습니다

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편,,,ㅠㅠ  (2) 2009.04.23
JAVA숙제,,,  (1) 2009.04.09
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
도메인 따위 살돈도 없고, 학교에서 밖으로 포트가 열리지도 않으니,,,
주소는 요기,,,>> http://10.62.11.48:8081/
업로드 하실분은 저에게 비밀댓글로 아뒤랑 비번을^^

'생활' 카테고리의 다른 글

동아리 폐부  (0) 2012.03.10
크롬 확장 scribefire를 써보자  (1) 2012.02.23
Haven and Hearth 시작!  (1) 2011.02.09
[TIP!]windows에서 linux의 하드 링크기능 사용하기  (0) 2010.02.07
더미 파일 만들기  (0) 2009.12.29

앞으로 C++은 월,수,금
자바는 화,목,토 에 올리도록 노력해 볼께요,,
제가 요즘 생활이 많이 불규칙해져서,, 언제 생각나면 더 올릴지는 모르고, 몸이 안좋다고 빼먹을지는 모르지만,,, 기본적인 업뎃 날짜는 이렇게 해 놓을게요,,
요즘 동아리에 많이 가입하는바람에,,,

p.s. 동아리에 가입하는거 제한은 없겠죠?
지금 연극, 방송, 기타, 컴터에 가입하려는데,,,

'대학생활' 카테고리의 다른 글

지금은 집 입니다.  (0) 2009.12.22
UNIST 2009년 2학기 기말고사 시간표  (0) 2009.12.05
내맘대로 강좌 공통편 1  (0) 2009.03.20
학생증 드디어 나왔습니다!!!  (0) 2009.03.16
내맘대로 강좌 시작!!  (1) 2009.03.16

지금 와일리를 보다가 나온건데, 콘솔이 아닌 다이얼로그로 입력, 출력하는법 발견,,

Call the static showInputDialog method of the JOptionPane class, and supply the string that prompts the input from the user. For example,
String input = JOptionPane.showInputDialog("Enter price:");
That method returns a String object. Of course, often you need the input as a number. Use the Integer.parseInt and Double.parseDouble methods to convert the string to a number:
double price = Double.parseDouble(input);
You can also display output in a dialog box:
JOptionPane.showMessageDialog(null, "Price: " + price);
Finally, whenever you call the showInputDialog or showMessageDialog method in a program that does not show any other frame windows, you need to add a line
System.exit(0);
to the end of your main method. The showInputDialog method starts a user interface thread to handle user input. When the main method reaches the end, that thread is still running, and your program won't exit automatically. To force the program to exit, you need to call the exit method of the System class. The parameter of the exit method is the status code of the program. A code of 0 denotes successful completion; you can use nonzero status codes to denote various error conditions.
                                                              (원문 출처 와일리,,,)

이 장에 의하면
JOptionPane.showInputDialog("Enter price:");
이 함수는 Enter Price:라는 문구가 들어간 입력 다이얼로그를 띄워주고 다이얼로그에서 확인이 눌리거나 엔터가 쳐질경우 그 값을 srting 형으로 반환합니다.
그 뒤 Double.parseDouble(string)이나 Int.parseInt(string)함수로 각각의 형으로 고칠수 있는것 같구요,,,,
근데 이거를 사용하면 main함수 마지막에
system.exit(0);을 꼭 써야 한다네요,,,

'대학생활 > JAVA' 카테고리의 다른 글

JAVA숙제,,,  (1) 2009.04.09
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23