본문 바로가기

ETC Programmings

(80)
C로 LinkedList 구현 +_+// (아 힘들었어;; ㅋㅋ) #include #include typedef struct Node { int data; struct Node *next; } node; typedef struct LinkedList { int length; struct Node *fNode; }linkedList; node* firstNode; int length; void initList(struct LinkedList*); node* getNodeAt(struct LinkedList*, int); void add(struct LinkedList*, int); void addInIndex(struct LinkedList*, int , int); void erase(struct LinkedList*, int); void replace(struct Li..
C로 ArrayList 구현 +_+ 구조체 배운 기념으루다가 ㅋ #include #include #define INIT_LENGTH 100; struct ArrayList { int *dataSet; int length; int initLength; } list; void initList(); void initListSize(int); void add(int); void addInIndex(int , int); void erase(int); void replace(int, int); void reset(); void display(); int get(int); int isFull(); int isEmpty(); void initList() { list.initLength = INIT_LENGTH; list.dataSet = calloc(list.initLength,s..
C#으로 LinkedList 구현 ^^ C#으로 구현한 LinkedList 여전히 null 값에 대한 의문이 남는다. Nullable을 구현해 줘야 되는거 같기는 한데, 제너릭에 자바에서 처럼 extends 라는 키워드 대신에 where 라는 키워드를 사용한다고 하는데 아직까지는 잘 모르겠다. 때문에 null 값으로 지정하지 않고 구현해봐따. ㅋ using System; using System.Collections.Generic; using System.Text; namespace List { public class LinkedList : ListInterface { private Node firstNode; private int length; public LinkedList() { reset(); } public void add(T entr..
C#으로 ArrayList 구현 ^^ 문법도 익히고 C#도 손에 익힐수 있었던 시간.. 뭐 List 에 대한 자료구조는 이해하고 있었기 때문에 만드는데 그렇게 오래 걸리지는 않았다 ^^ 큭큭;; using System; using System.Collections.Generic; using System.Text; namespace List { class ArrayList : ListInterface { private T[] dataSet; private int length; private int initSize; public ArrayList() { reset(); } public ArrayList(int size) { this.initSize = size; this.dataSet = new T[initSize]; this.length = ..
구조체 배워보기... (안되던 부분 수정버젼) #include #include #include struct food { char name[15]; int portion_weight; int calories; }; // 얘는 작동안함. struct food init(char *setName, int setWeight, int setCalories){ struct food setMeal; strcpy(setMeal.name, setName); setMeal.portion_weight = setWeight; setMeal.calories = setCalories; return setMeal; } void main(){ struct food meals[10]; int i; for(i = 0 ; i < 10 ; i++){ meals[i] = init("헉",..
구조체 배워보기.. #include #include #include struct food { char name[15]; int portion_weight; int calories; } meal1, meal2, meal3; int result(){ return meal1.calories + meal2.calories + meal3.calories; } // 얘는 작동안함. void init(struct food setMeal, char *setName, int setWeight, int setCalories){ strcpy(setMeal.name, setName); setMeal.portion_weight = setWeight; setMeal.calories = setCalories; } void main(){ strcpy(..
MakeUp Quiz(풀이) #include #include #define True 1 #define False 0 void swapStr(char *base, char *target); void shift(char *pstr, int n); void order_char(char *pstr, int n); double sum_primed_position(double arr[], int n); void bubble(double arr[], int n); void swap(double*, double*); int occurrence(char *pstr, char c); void zigzag_scan(double *pa, double *pza); int isPrimed(int number); void swapStr(char *base, ..
MakeUp Quiz 다음 코드를 활용하여 프로그램을 완성하라. void shift(char *pstr, int n); void order_char(char *pstr, int n); double sum_primed_position(double arr[], int n); void bubble(double arr[], int n); void swap(double*, double*); int occurrence(char *pstr, char c); void zigzag_scan(double *pa, double *pza); main(int argc, char *argv[]) { int num; char c_array[128]; double *a; double coeff[4][4], zz_coeff[16]; if(argc