This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
execlp("ps", "ps", "-o", "pid,ppid", NULL); | |
perror("exec ps"); | |
exit(1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
gcc -g main.c | |
st: | |
gcc -g struct.c -o struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alist = [34, 6, 9, 10, 11, 23, 26, 28, 30] | |
# alist = [26, 28, 30, 34, 56,9, 10, 11, 23] | |
def find(k): | |
return binarysearch(alist, k, 0, len(alist)-1) | |
def binarysearch(la, k, start, end): | |
if start > end: | |
return -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 环形队列 | |
* author: haicheng.bi | |
*/ | |
#include <stdio.h> | |
#define MAX_ROW 5 | |
#define MAX_COL 5 | |
#define SIZE 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 迷宫问题 | |
* author: haicheng.bi | |
*/ | |
#include<stdio.h> | |
#define MAX_ROW 5 | |
#define MAX_COL 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* pow | |
* | |
* author: haicheng.bi | |
*/ | |
#include<stdio.h> | |
#include<time.h> | |
double mypow(double base, int n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 平方根 | |
* author: haicheng.bi | |
*/ | |
#include<stdio.h> | |
double myabs(double n) | |
{ | |
if(n < 0) { | |
return -n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#description: switch network to an avaliable one | |
#author: haicheng.bi | |
netstatus=$(nmcli general status | awk 'NR > 1 { print $2 }') | |
ifcfg_path="/etc/sysconfig/network-scripts/ifcfg-有线连接_1" | |
ip=$(sed -n 's/IPADDR=\(.*\)/\1/p' $ifcfg_path) | |
gateway=$(sed -n 's/GATEWAY=\(.*\)/\1/p' $ifcfg_path) | |
function echo_with_date { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 在字符串中查找字符 | |
* 返回字符所在位置 | |
* author: haicheng.bi | |
*/ | |
#include<stdio.h> | |
#define N 10 | |
int a[N] = {1, 12, 3, 14, 5, 46, 7, 78, 79, 1890}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 折半查找 | |
* author: haicheng.bi | |
*/ | |
#include<stdio.h> | |
#define N 10 | |
int a[N] = {1, 4, 5, 6, 7, 8, 10, 19, 20, 300}; | |
int binary_search(int start, int end, int k) |
NewerOlder