본문 바로가기

반응형

System Programmings

(80)
[Java] 부분 일치하는 문자 검색 노홍철 박명수 정준하 하하 유재석 정형돈 길 이렇게 있을때 '하'와 부분일치하는 문자를 검색하면 아래와 같은 결과가 나온다. 정준하 하하 이렇게 검색하려면 String에 포함되 있는 메소드 'contains' 함수를 쓰면 된다. 예를 들면 public class main { public static void main(String [] args){ String [] x = {"노홍철", "유재석", "정준하", "정형돈", "길", "하하"}; String text = "하"; for(int i=0; i < x.length; i++){ if(x[i].contains(text)) System.out.println(x[i]); } } }
[Java] 오픈소스에 사용된 유용한 메소드들 /** * * 스트링이 숫자로만 이루어져 있는지 확인하여 결과를 반환한다. * * @param text 대상 문자열. * @return boolean 숫자인 문자로만 되어있으면 true, 아니면 false. * */ public static boolean isNumeric (String text) { if (text == null || text.trim().length()==0) return false; int size = text.length(); for(int i = 0 ; i
[C] Cygwin에서 ssl 사용하기 먼저 ssl 설치하기 1. home 폴더에 openssl.tar.gz을 'tar zxvf 파일명' 명령어로 푼다 (ex tar zxvf openssl- 1.0.0d.tar.gz) 2. 압축 푼 폴더안에서 ./config 입력 3. make 입력 4. make test 입력 후 에러 유무 확인 5. make install End gcc -o test test.c -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto test는 gcc할 파일명 ---------------------------------------------------- 여담------------------------------------------ -I 옵션은 헤더 파일의 경로를 정한다. 즉, m..
[C] 난수 생성 #include #include // for srand #include // for seed int main() { srand((unsigned)time(NULL)); printf("%d\n", rand()); printf("%d\n", rand()%100); return 0; }
[C] getcputc.c - 파일 복사 및 문자열 복사 #include "apue.h" #include "apue.h" int main() { int c; while((c=getc(stdin))!=EOF) if(putc(c, stdout)==EOF) err_sys("output error"); if(ferror(stdin)) err_sys("input error"); exit(0); } /* * #include * int getc(FILE *fp); * int fgetc(FILE *fp); * int getchar(void); * * Warning : EOF & FILE *fp * * ./a.out newfile */
[C] ls.c - 현재 디렉토리의 파일 및 폴더 출력 #include "apue.h" #include int main(int argc, char *argv[]) { DIR *dp; struct dirent *dirp; if(argc!=2) err_sys("using : directory_name"); if((dp=opendir(argv[1]))==NULL) err_sys("can't open %s", argv[1]); while((dirp=readdir(dp))!=NULL){ printf("%s\n", dirp->d_name); } closedir(dp); exit(0); } /* * * struct dirent{ * ino_t d_ino; // i-node number * char d_name; // Null-terminated filename * } *..
[C] Advanced Programming In The Unix Environment - Second Edition 여러 예제에 포함될 apue.h와 error.c 파일 error.c apue.h
[C++] 퀵 정렬 (Quick Sort) C++ 이용한 다른 소스 #include using namespace std; void quicksort(int low, int high, int s[]); void partition(int low, int high, int& pivotpoint, int s[]); int main() { int s[50]={0}; int low, high; int i, n; cout n; while(n50){ // 적당한 값이 나올때 까지 반복 cout s[i]; low=0; high=n-1; for(i=0; i

반응형