- 博客(136)
- 收藏
- 关注
原创 打乱数组顺序
#include <stdio.h>#include <stdlib.h>#include <time.h>#define ARRAY_SIZE 50int ElementSwitch(int a[], int first, int second){ int tmp; tmp = a[first]; a[first] = a[second]; a[second] = tmp; return 0;}int Shuffle(int a[].
2021-09-24 13:03:24
430
1
原创 C 基本线程
#include <stdio.h>#include "tinycthread.h"int SayHello(char *name){ printf("Run in new thread [%#x]: Hello, %s\n", thrd_current(), name); return 0;}int main(void){ thrd_t new_thread; int result = thrd_create(&new_thread, SayHello, .
2021-09-23 17:55:43
146
原创 N的阶乘,递归
#include <stdio.h>unsigned Factorial(unsigned n){ if(n == 0){ return 1; } else{ return n * Factorial(n - 1); }}int main(void){ printf("3! %d\n", Factorial(3)); printf("5! %d\n", Factorial(5)); printf("8! %d\n", Factorial(8)).
2021-09-23 15:12:44
213
原创 C语言 变长参数
#include <stdio.h>#include <stdarg.h>void HandleVarargs(int arg_count, ...){ //定义 va_list用于获取变长参数 va_list args; //开始便利 va_start(args, arg_count); for (int i = 0; i < arg_count; ++i) { //取出对应参数 int arg = va_arg(args, int).
2021-09-23 14:42:29
117
原创 控制器双活 负载均衡
所谓的传统存储双控双活,我的目前的理解是这样,首先,目的是啥?有两个1、部件冗余,也就是高可用(HA)2、负载均衡双控的HA模式有三种,1、HA:也就是A-P模式,在某一时刻只有一个控制器处理上层下来的业务,另一个控制器闲置,只有在活动控制器出现故障的时候,才切换到这个闲置的控制器,这种方式由于太过于土豪,等于花了两样的钱,只能使一样,所以基本没人用这种方式了。2、
2018-01-27 23:18:32
5933
原创 show_ip.sh
#!/bin/bash##ip_addr=$(ifconfig | grep "inet addr" | grep -v "127" | awk '{print $2}'| awk -F ':' '{print $2}')echo "your ip address is ${ip_addr}"your ip address is 172.16.54.207
2015-12-11 13:23:27
585
原创 mytrans.sh
#!/bin/bash##echo "the first para is $1"echo "the second para is $2"echo "the third para is $3"echo "the number of para is $#"echo "the para are $*"echo "the PID is $$"echo "the last PID is $
2015-12-11 11:31:11
483
原创 hello
#!/bin/bash##function say_hello(){ echo "Enter your name:" read name echo "Hello ${name}"}echo "Programme start here......"say_helloecho "Programme Ends."
2015-12-10 16:01:43
305
原创 清理/var/log/messages的脚本
#!/bin/bash#this is clearcat /dev/null > /var/log/messagesecho "message clear up"
2015-12-10 15:21:46
2439
原创 列出场景中所有对象
/* 列出场景中所有对象 显示名称和类型 */proc listAll(){ print("\nNodes..."); //定义一个数组nodes,执行ls命令,把结果存入数组 string $nodes[] = `ls`; //执行for循环:如果node在nodes中,则对node执行 objectType命令,并把结果存储在变量nodeType中
2014-04-01 10:13:44
777
原创 一个简单的类 和 调用
#include using namespace std;class Time{public: //构造函数 Time(); //设置时间函数 void setTime(int, int, int); //24小时制显示时间 void showTime24(); //12小时制显示时间 void showTime12();private: int hour; int
2014-03-21 12:51:32
580
原创 简单的函数模版
#include using namespace std;template T volume(T side1, T side2, T side3){ return side1 * side2 * side3;}int main(){ cout << volume(1, 2, 3) << endl; cout << volume(1.2, 2.0, 3.3) << endl;
2014-03-20 11:32:19
559
原创 function overload 2
#include #include using namespace std;int square(int);double square(double);int main(){ cout << square(8) << endl; cout << square(9.3) << endl; return 0;}int square(int edge){
2014-03-19 23:25:12
824
原创 function overload
#include #include using namespace std;int square(int);double square(double);int main(){ cout << square(8) << endl; cout << square(9.3) << endl; return 0;}int square(int edge){
2014-03-19 23:17:57
735
原创 一个c++小程序
#include int mycube(int);using namespace std;int main(){ int side; cout << "enter the cube side: " << endl; cin >> side; cout << "the volume of the cube is: " << mycube(side) <<
2014-03-18 21:29:17
660
原创 (三)顺序栈main函数
#include "seqstack.h"int main(){ SeqStack stack; initSeqStack(&stack); printf("%d\n", isEmptySeqStack(stack)); PushSeqStack(&stack, 111); PushSeqStack(&stack,
2014-03-18 21:05:46
3166
2
原创 (二)顺序栈函数定义
#include "seqstack.h"int initSeqStack(SeqStack* S){ S->top = 0; return 0;}int clearSeqStack(SeqStack* S){ for (int i=0; itop; i++) S->data[i] = 0; S->top = 0; return 0
2014-03-18 21:04:53
892
原创 (一)顺序栈头文件
#include #include #define STACKMAXSIZE 10typedef struct seqstack{ int data[STACKMAXSIZE]; int top;}SeqStack;int initSeqStack(SeqStack*);int destroySeqStack(SeqStack*);int clearS
2014-03-18 21:03:46
1706
原创 一个斐波那契数列
#include #define FIBONSIZE 20int main(){ int a = 0, b = 1, c, fibon[FIBONSIZE]; for (int i = 0; i < FIBONSIZE; i++){ c = a + b; fibon[i] = c; a = b; b = c; } for (int i = 0; i < FIBONS
2014-03-18 09:31:55
550
原创 (三)链表main函数
#include "linklist.h"int main(){ linklistPtr head; create_linklist(&head); printf("%d\n", head->data); insert_linklist(&head); traversal_linklist(head); del_linklis
2014-03-15 23:44:20
2606
原创 (二)链表头文件
#include #include //define a link node structtypedef struct linklistnode{ int data; struct linklistnode *next;}linklist, *linklistPtr;//declaration create_linklistint create_linklist(l
2014-03-15 23:43:22
971
原创 (一)链表函数定义文件
#include "linklist.h"int create_linklist(linklistPtr* L){ if(!((*L) = (linklistPtr)malloc(sizeof(linklist)))) return 1; (*L)->data = 234; (*L)->next =NULL; return 0; }
2014-03-15 23:41:55
685
原创 (三)线性表菜单
#include "seqlist.h"int main(){ //定义一个线性表变量 SqList sqlist; int choose, position, value; do{ printf("************ seqlist menu ************\n"); printf("\t1 创建顺序表\n"); printf("\t2 判断顺序表是否为空
2014-03-14 17:27:34
1001
原创 (二)函数定义文件
#include "seqlist.h"//1 创建一个顺序表int create_SqList(SqListPtr L){ for (int i = 0; i < LISTMAXSIZE; i++) L->data[i] = 0; L->length = 0; return 0;}//2 判断顺序表是否为空int isEmpty_SqList(SqList L){ re
2014-03-14 17:26:50
762
原创 (一)线性表头文件
#include #include #ifndef LISTMAXSIZE#define LISTMAXSIZE 10#endif//定义一个顺序表typedef struct SqList{ int data[LISTMAXSIZE]; int length;}SqList, *SqListPtr;//1 创建一个顺序表int create_SqList(SqList
2014-03-14 17:25:55
7218
原创 二叉树的建立 与 遍历
#include #include //定义一个树节点的结构struct treeNode{ char data; struct treeNode *lchild, *rchlid;};//创建树的各个节点int create_tree(struct treeNode**);//遍历二叉树int show_tree(struct treeNode*);int main(
2014-03-13 15:13:31
671
原创 初始化一棵树
#include #include //定义一个树节点的结构struct treeNode{ char data; struct treeNode *lchild, *rchlid;};//初始化一棵树的根节点int initial_tree(struct treeNode**);int main(){ //定义一个指向树节点的指针,并初始化为空 struct tre
2014-03-13 12:39:02
3689
1
原创 顺序栈的一般操作
#include //define the size of array#define MAXSIZE 100//define new data type: stackstruct stack{ int data[MAXSIZE]; int top;};//defint var seqStacktypedef struct stack seqStack;//crea
2014-03-11 22:28:51
541
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人