일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- error
- web3js
- quick-start
- bigquery
- 다윈
- Exception
- dataginding
- Android
- log
- null safety
- test
- Realm
- C
- fabic
- LAYER_TYPE_SOFTWARE
- 컴파일
- porterduff
- kotlin
- ethereum
- Glide
- vuepress
- fabric-sdk-java
- hardwareacceleration
- Hyperledger
- convert
- 안드로이드
- coroutines
- 스트리밍
- Gradle
- firebase
- Today
- Total
목록프로그래밍/C / C++ (41)
날마다 새롭게 또 날마다 새롭게
#inlcude #include 문자열 정렬 프로그램 #define MAXLINES 5000 /* max lines to be sorted */char *lineptr[MAXLINES]; /* pointers to text lines */ int readlines(char *lineptr[], int nlines);void writelines(char *lineptr[], int nlines);void qsort(void *lineptr[], int left, int right, int(*comp)(void*,void*));int numcmp(char *, char *); /* sort input lines */int main(int argc,char *argv[]){int nlines; /* numbe..
#include #include #define MAXLINE 100 int getline(char *line, int max); /* find : print lines that match pattern from 1st arg */int main(int argc, char *argv[]){char line[MAXLINE];int found=0;long lineno=0;int c, except=0,number=0; // 선택매개변수 처리용, ex)-n, -x ... while(--argc>0 && (*++argv)[0]=='-')while(c=*++argv[0])switch(c) {case 'x':except = 1;break;case 'n':number = 1;break;default:printf("fin..
#include /* echo command-line arguments; 1st version */main(int argc, char *argv[]){int i; for(i=1;i1)?" ":"");printf("\n");return 0;}
/* month_name : return name of n-th month */char *month_name(int n){static char *name[] = { "Illegal month", "January","February","March", "April","May,"June","July", "August","September","October", "November","December"}; return (n12)?name[0]:name[n]; }
static char daytab[2][13] = { {0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}}; /* day_of_year : set day of year from month & day */int day_of_year(int year, int month, int day){int i, leap; leap = ((year%4==0)&&(year%100!=0))||year%400==0;for(i=0;i daytab[leap][i]; i++)yearday -= daytab[leap][i]; *pmonth = i;*pday = yearday;}
/* qsort : sort v[left] ... v[right] into increasing order */void qsort(char *v[], int left, int right){int i, last;void swap(char *v[], int left, int right); if(left >= right)return ;swap(v, left, (left + right)/2);last = left;for(i = left +1; i
#include #include #define MAXLINES 5000char *lineptr[MAXLINES]; int readlines(char *lineptr[], int nlines);void writelines(char *lineptr[], int nlines); void qsort(char *lineptr[], int left, int right); main(){int nlines;if((nlines = readlines(lineptr, MAXLINES))>=0) {qsort(lineptr,0,nlines-1);writelines(lineptr,nlines);return 0;} else {printf("error : input too big to sort \n");return 1;} } #de..
/* readlines : read input lines */int readlines(char *lineptr[], int maxlines){int len, nlines;char *p, line[MAXLEN]; nlines=0;while(len=getline(line, MAXLEN))>0)if(nlines >= maxlines || (p=alloc(len))==NULL)return -1;else {line[len-1]='\0';strcpy(p,line);lineptr[nlines++]=p;}return nlines;}
/* getline: get line into s, return length */int getline(char s[], int lim){int c, i;i=0;while(--lim>0 && (c=getchar())!=EOF && c!='\n')s[i++]=c;if(c=='\n')s[i++]=c;s[i]='\0';return i;}
/* strcmp : return t version 1 */int strcmp(char *s, char *t){int i;for(i=0;s[i]==t[i];i++)if(s[i]=='\0')return 0;return s[i]-t[i];} /* strcmp : return t version 2 */int strcmp(char *s, char *t){for(;*s==*t;s++,t++)if(*s=='\0')return 0;return *s - *t;}