Skip to content

Instantly share code, notes, and snippets.

View bihicheng's full-sized avatar
💭
I may be slow to respond.

bihicheng bihicheng

💭
I may be slow to respond.
View GitHub Profile
#include <unistd.h>
#include <stdlib.h>
int main(void)
{
execlp("ps", "ps", "-o", "pid,ppid", NULL);
perror("exec ps");
exit(1);
}
all:
gcc -g main.c
st:
gcc -g struct.c -o struct
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
/**
* 环形队列
* author: haicheng.bi
*/
#include <stdio.h>
#define MAX_ROW 5
#define MAX_COL 5
#define SIZE 10
/**
* 迷宫问题
* author: haicheng.bi
*/
#include<stdio.h>
#define MAX_ROW 5
#define MAX_COL 5
/*
* pow
*
* author: haicheng.bi
*/
#include<stdio.h>
#include<time.h>
double mypow(double base, int n)
/*
* 平方根
* author: haicheng.bi
*/
#include<stdio.h>
double myabs(double n)
{
if(n < 0) {
return -n;
#!/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 {
/*
* 在字符串中查找字符
* 返回字符所在位置
* author: haicheng.bi
*/
#include<stdio.h>
#define N 10
int a[N] = {1, 12, 3, 14, 5, 46, 7, 78, 79, 1890};
/*
* 折半查找
* 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)