Follow these steps to install g++ (the GNU C++ compiler) for Windows. There is no room for creativity here; you must follow the directions exactly.
Pick the drive and a folder in which you want to install g++. I'll assume that it is C:, but you can choose a different one. If you choose a different drive or a different folder, you'll need to adapt the directions below accordingly.
Download full.exe, an about 14 megabyte executable, to C:\full.exe by right-clicking on the link. Use Save Link As... or Save Target As... Be sure the browser saves the file as C:\full.exe.
Run the downloaded executable. This will install g++ (and a lot of other things that you don't really need) on your hard drive. Go to the C: drive using Windows Explorer and double-click on full.exe. Or, open a DOS window (Start > Programs > Command Prompt), connect to the C: drive using the cd command, and type full.
Locate where the bin folder was created for the g++ installation. On my Windows XP machine, it was created in the following path:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
You now should add it to the PATH environment variable. You do that by following:
Start -> Control Panel -> System -> Advanced -> Environment Variables
At this point you can see the PATH variable either in the User Variables or in the System Variables. Add the g++ path into the PATH variable. You add it to the end of the existing value separated by a semicolon (';'). Make sure that you do not lose the original value. You are just appending more to the end separated by a semicolon.
Restart your computer. A Cygnus Solutions entry will appear in your Programs menu, and an icon may appear on your desktop. Don't use them! You will use it using the g++ command on a DOS prompt as explained below.
You should now be able to run g++ from a DOS (Command Prompt) window. For example, to compile a file called C:\mine\hello.cpp, connect to the C:\mine folder and enter
g++ -g hello.cpp -o hello -lm
You'll then be able to run the compiled program by entering hello in the DOS window.
If you've installed Emacs as described here, you will also be able to run g++ from Emacs. If, when you do this, Emacs tries to compile with the command make -k, you made a mistake during the Emacs installation. If you want to learn how to run g++ on emacs, see here.
If you'd like to learn more about where this free compiler came from, we downloaded it from an older site of http://sourceware.org/cygwin/.
If you wish to clean up a little, you may delete the file: full.exe at this point. Your g++ compiler is installed under C:\cygnus.
======================================================================================
사실 위에서 말하는대로 하지 않아도 상관없다.
파일을 받고 더블클릭하면 알아서 설치된다.
설치가 끝나고 나면 환경변수를 등록하도록 하자.
내컴퓨터 오른쪽클릭 -> 속성 -> 고급 -> 환경변수
지정된 PATH + ;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
//heap으로 구현하는 것이 적당하나 이 source에서는 linked list로 구현 bool MySets::insertElement(int value) { Element* current = root; Element* pre_node = current; // 오름차순으로 insert sorting한다 // 새로운 값이 들어갈 자리 확인(입력할 값보다 큰값 앞이거나 리스트의 마지막 while((current != NULL) && (current->getData() < value)) { pre_node = current; current = current->getLink(); } Element* newNode = new Element(value, pre_node->getLink()); //입력할 노드 pre_node->setLink(newNode); return true; }
//리스트에서 같은 값을 찾아 가장 먼저 나오는 값을 지운다 bool MySets::deleteElement(int value) { Element* current = root; Element* pre_node = current; while((current->getLink() != NULL) && (current->getData() < value)) { pre_node = current; current = current->getLink(); }
if(current->getData() != value) return false; //찾는 값이 리스트에 없음
Design and implement (in C++) an ADT Array that can dynamically grow and shrink as integers are data is inserted and removed. // ADT array 을 하나 맏르어줘서 엄청나게 커질수도 작아질수도 있게 만들어 주는거네요 . Access time to any item in an array (via it's index) should be constant. The cost of an insert into the middle of an array may be O(n). Indexes need not start at zero and may be negative.
The ADT should include the following:
-A default constructor that creates an empty array starting at index 0.
-A constructor taking an intdata [] array that builds an array populated with the items in the array starting at index 0.
-A constructor taking a range int low, int high that builds an empty array ranging from the low index to the high. (Pre: high >= low.)
-A copy constructor array( const array& that ) .
-A destructor.
-An accessor int size( ) that returns the size of (number of entries in) the array.
-An accessor int find( intdata n ) that returns the index of element n in the array.
-An accessor int at( intdata n ) that returns the integer at the given index n.
-A mutator void insert( intdata n ) that inserts the element n at the end of the array.
-A mutator void insert( intdata n, index i ) that inserts the element n into the array at index position i.
-Amutator void erase( int index ) that removes the element at the given index position in the array.
-A mutator void clear( ) that empties the array.
Overload the [] operator
Overload the assignment operator =
Overload the operator == to test array equality.
Overload the operator != to test array inequality.
ADT란게 자료의 type에 무관하게 사용하겠다는 겁니다. 뎃글에 자료형을 물어보신 글이 있던데 특정한 자료가 정해진 것아닙니다. C++ 문법에 template이 있는데 이 부분은 표준이 제대로 안되어 있어서 컴파일러마다 조금씩 다르기도 합니다.
배열의 크기가 동적으로 커졌다고 줄었다가 한다고 되어 있습니다. 배열로 지정하고 크기에 따라 deep copy를 통해 크기가 다른 배열로 바꿀 수도 있습니다만 문제에서 O(n)이 예상된다고 하니 링크드리스트를 원하는 것으로 보입니다.
int begin(){return idx_begin;} int size(){return arraySize;}
int find(T data) // 같은 element가 있을 경우 가장 앞선 index를 return { int index = idx_begin; DataNode<T> *current = root->getLink(); while(current != NULL) { if(current->getEntry() == data) return index; current = current->getLink(); index++; } return idx_begin-1; // 찾는 값이 없음 }
T at(int index) { DataNode<T> *current = root; for(int i = idx_begin; i <= index; i++) { current = current->getLink(); } return current->getEntry(); }
//ADTArray<char> *myArray = new ADTArray<char>(); return 0; }
한시간 넘게 붙잡고 있었는데 엉망이다. 귀찮아서 다 inline으로 해버렸고 A constructor taking a range int low, int high that builds an empty array ranging from the low index to the high. (Pre: high >= low.) 이부분... 생성자에서 low와 high값을 argument로 던져주고 배열사이즈를 계산해서 생성하란 것 같은데 무슨 뜻인지, 왜 필요한지 몰라서 제대로 못했다. 그리고 test결과 =연산자가 제대로 작동하지 않는다. 제대로 연산은 되는데 const &로 parameter를 맞추니까 오류나고 그냥 해버리니까 연산이 끝난 후 R-value의 링크가 사라진다. 뭐냐고..
아무튼 문제에 보면 Indexes need not start at zero and may be negative. 이렇게 되어 있는데 그러면 생성할 때 배열의 low와 high를 정하는 것이 아니라 method중에 begin을 결정하는 method가 있으면 되는거 아닌가? 문제를 만든 사람은 뭘 생각한 거지? 내 영어실력이 문젠가? 아무튼 제대로 이해한 사람 있으면 좀 알려주..