Skip to content
Open

Jio #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.errorSquiggles": "disabled"
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@
* 2주차 과제
* 3주차 과제
* 4주차 과제
* 5주차 과제

과제1
이 수업에서 배우고 싶은 것 : 대략적인 자료구조 내용
얻어가고 싶은 것 : 자료구조를 배우다 어려운 파트나 모르는 파트 해결하고 가기
* 5주차 과제
4 changes: 4 additions & 0 deletions w1/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
여기에 1주차 과제를 작성해주시면 됩니다!

과제1
이 수업에서 배우고 싶은 것 : 대략적인 자료구조 내용
얻어가고 싶은 것 : 자료구조를 배우다 어려운 파트나 모르는 파트 해결하고 가기
128 changes: 124 additions & 4 deletions w1/test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,127 @@
#include <iostream>
#include <stdexcept>
using namespace std;

int main()
{
cout << "hello world";
}
// int main()
// {
// cout << "hello world";
// }

// class ArrayStack {
// private:
// int *arr;
// int top;
// int capacity;
// public:
// ArrayStack(int capacity)
// {
// this->capacity = capacity;
// this->arr = new int[capacity];
// this->top = -1;
// };
// ~ArrayStack() {
// delete[] arr;
// }
// void push(const int &x) {
// arr[top+1] = x;
// top += 1;
// }
// int pop() {
// if(!this->empty()) {
// int a = arr[top];
// top -= 1;
// return a;
// }
// else {
// throw out_of_range("");
// }
// }
// int peak() const {
// if(!this->empty()) {
// return arr[top];
// }
// else {
// throw out_of_range("");
// }
// }
// bool empty() const {
// if (top == -1) {
// return true;
// }
// else {
// return false;
// }
// }
// int size() const {
// return top+1;
// }
// };

// int main() {
// ArrayStack stack(10);
// stack.push(10);
// stack.push(20);
// stack.push(30);
// std::cout << "Top: " << stack.peak() << std::endl;
// std::cout << "Pop: " << stack.pop() << std::endl;
// std::cout << "Size: " << stack.size() << std::endl;
// return 0;
// }
// stack은 배열을 통해 구현가능
// Node를 통해서도 구현가능
// queue도 배열과 node를 통해서 구현가능

// struct Node {
// int data;
// Node *next;

// Node(int value) :data(value), next(nullptr) {}
// };

// class LinkedQueue {
// private:
// Node *front;
// Node *rear;
// int currentSize;
// public:
// LinkedQueue() {
// currentSize = 0;
// front = nullptr;
// rear = nullptr;
// }
// ~LinkedQueue();
// void enqueue(int x) {
// if(front == nullptr) {
// Node node(x);
// front = &node;
// rear = &node;
// currentSize++;
// }
// else {
// rear = rear->next;
// rear->data = x;
// currentSize++;
// }
// }
// int dequeue() {
// Node *temp = front;
// front = nullptr;
// while(this->rear->next == this->front) {
// front = rear->next;
// }
// currentSize--;
// return temp->data;
// }
// int frontElement() const {
// return front->data;
// }
// int backElement() const {
// return rear->data;
// }
// bool empty() const {
// return front == nullptr;
// }
// int size() const {
// return currentSize;
// }
// };
Binary file added w1/test.exe
Binary file not shown.
Binary file added w1/test.ilk
Binary file not shown.
Binary file added w1/test.obj
Binary file not shown.
Binary file added w1/test.pdb
Binary file not shown.
Binary file added w1/vc140.pdb
Binary file not shown.
39 changes: 39 additions & 0 deletions w2/w2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main() {
int N;
cin >> N;

stack<int> s;

while (N--) {
string cmd;
cin >> cmd;

if (cmd == "push") {
int x;
cin >> x;
s.push(x);
}
else if (cmd == "pop") {
if (s.empty()) cout << -1 << '\n';
else {
cout << s.top() << '\n';
s.pop();
}
}
else if (cmd == "size") {
cout << s.size() << '\n';
}
else if (cmd == "empty") {
cout << s.empty() << '\n';
}
else if (cmd == "top") {
if (s.empty()) cout << -1 << '\n';
else cout << s.top() << '\n';
}
}
}
Binary file added w3/vc140.pdb
Binary file not shown.
170 changes: 170 additions & 0 deletions w3/w3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// #include <iostream>
// #include <vector>
// using namespace std;

// class Node {
// public:
// int data;
// Node *next;
// Node *prev;
// Node(int d) {
// data = d;
// }
// };

// class DLL {
// private:
// Node *head;
// Node *tail;
// Node *cursor;
// int size;
// public:
// DLL() {
// head = new Node(-1);
// tail = new Node(-1);
// cursor = nullptr;
// size = 0;
// }
// void insertNext(Node *position, int data) {
// Node *newnode = new Node(data);

// if(size == 0) {
// head->next = newnode;
// newnode->prev = head;

// tail->prev = newnode;
// newnode->next = tail;
// }
// else {
// Node *n = position->next;

// position->next = newnode;
// newnode->prev = position;

// n->prev = newnode;
// newnode->next = n;
// }
// }
// void insertFront(Node *position, int data) {
// Node *newnode = new Node(data);

// if(size == 0) {
// Node *n = head;

// head = newnode;

// newnode->next = n;
// n->prev = head;
// }
// else {
// Node *n = position->prev;
// position->prev = position;

// n->next = position;
// position->prev = n;

// n->prev = position->prev->prev;

// }
// }
// void remove(Node *position) {
// while(cursor == position)
// }
// };
//집가서 수정하고 실행할 것


#include <iostream>
using namespace std;

struct Node {
public:
int data;
Node *next;
Node *prev;
Node(int d) {
data = d;
next = nullptr;
prev = nullptr;
}
};

class CircularList {
private:
Node *cursor;
int n;

public:
CircularList()
: cursor{nullptr}, n{0} {}

void append(int a) {
Node *newNode = new Node(a);

if(cursor == nullptr) {
this->cursor = newNode;
newNode->next = newNode;
newNode->prev = newNode;
}
else {
Node *last = cursor->prev;

newNode->next = cursor;
newNode->prev = last;

last->next = newNode;
cursor->prev = newNode;


}
n++;
}

int remove() {
int data = cursor->data;
if(n==1) {
cursor = nullptr;
}
else {
Node *toRemove = cursor;
Node *preNode = cursor->prev;
Node *nextNode = cursor->next;

preNode->next = nextNode;
nextNode->prev = preNode;
cursor = nextNode;
}
n--;
return data;
}

bool isEmpty() {
return n==0;
}

void move(int k) {
while(k--) {
cursor = cursor->next;
}
}
};

int main() {
int a, b;
cin >> a >> b;
int n{a};
CircularList cl;
for(int i{1}; i <= a; i++) {
cl.append(i);
}
cout << '<';
while(!cl.isEmpty()) {
cl.move(b-1);
cout << cl.remove();
if(n != 1) {
cout << ", ";
}
n--;
}
cout << '>';
}
Binary file added w3/w3.exe
Binary file not shown.
Binary file added w3/w3.ilk
Binary file not shown.
Binary file added w3/w3.obj
Binary file not shown.
Binary file added w3/w3.pdb
Binary file not shown.
Loading