C 프로그래밍(29)
-
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..
2008.05.10 -
구조체 배워보기... (안되던 부분 수정버젼)
#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("헉",..
2008.05.09 -
구조체 배워보기..
#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(..
2008.05.09 -
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, ..
2008.05.06 -
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
2008.05.06 -
atoi 함수를 이용해서 문자열의 숫자들의 합을 구하기
#include #include int checkNum(char *str); int getSize(char *str); int numCharToInt(char *str); int checkNum(char *str){ int sum = 0; int i; // 합을반영할숫자, 인덱스옮겨갈변수 char letter; for(i = 0 ; i '/' && str[i] < ':'){ letter = str[i]; sum += letter - '0'; } } return sum; } int getSize(char *str){ int size = 0; int i; for(i = 0;;i++){ if(str[..
2008.04.15