2012年1月5日

Linux 脚本编写基础(转)

摘要: 1. Linux 脚本编写基础1.1 语法基本介绍1.1.1 开头程序必须以下面的行开始(必须方在文件的第一行):#!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序。在这个例子中我们使用/bin/sh来执行程序。 当编辑好脚本时,如果要执行该脚本,还必须使其可执行。 要使脚本可执行:编译 chmod +x filename 这样才能用./filename 来运行1.1.2 注释 在进行shell编程时,以#开头的句子表示注释,直到这一行的结束。我们真诚地建议您在程序中使用注释。如果您使用了注释,那么即使相当长的时间内没有使用该脚本,您也能在很短的时间内明白该脚本... 阅读全文

posted @ 2012-01-05 16:52 ma6174 阅读(529) 评论(0) 推荐(0) 编辑

数据结构实验六:内部排序技术

摘要: 内部排序——快速排序#include<stdio.h>#include<stdlib.h>voidmyqsort(int*a,intlow,inthigh){inti,j;intc;c=a[low];i=low;j=high;while(i<j){while(a[j]>=c&&i<j)--j;a[i]=a[j];while(a[i]<=c&&i<j)++i;a[j]=a[i];}a[i]=c;if(i-1>low)myqsort(a,low,i-1);if(high>i+1)myqsort(a,i 阅读全文

posted @ 2012-01-05 16:20 ma6174 阅读(582) 评论(0) 推荐(0) 编辑

数据结构实验五:查找

摘要: 查找——实现监视哨法查找#include<stdio.h>#include<stdlib.h>intcmp(constvoid*a,constvoid*b){return*(int*)a-*(int*)b;}intmain(){inta[101],i;for(i=1;i<=100;i++)a[i]=rand()%100;for(i=1;i<=100;i++)printf("%d",a[i]);printf("\n");intkey;scanf("%d",&key);printf(" 阅读全文

posted @ 2012-01-05 16:19 ma6174 阅读(479) 评论(0) 推荐(0) 编辑

数据结构实验四:图的表示和实现

摘要: 图——邻接矩阵DFS和BFS:图——邻接表的DFS和BFS:#include<stdio.h>#defineINF65536#definemax100//邻接矩阵typedefstruct{//intno;//编号intinfo;//权值信息}vertex;//顶点typedefstruct{intedge[max][max];intv_num,e_num;//顶点v和边e//vertexvexs[max];//顶点信息}graph;typedefstructnode{intvetex;//顶点structnode*next;intinfo;//权值}node;typedefstr 阅读全文

posted @ 2012-01-05 16:18 ma6174 阅读(1067) 评论(0) 推荐(0) 编辑

数据结构实验三:二叉树及其应用

摘要: 设计两种输入模式建立一棵二叉树;输出该二叉树的深度;输出二叉树的子叶结点#include<stdio.h>#include<malloc.h>structnode{chardata;structnode*lchild;structnode*rchild;};node*creat(node*p){charch;scanf("%c",&ch);if(ch==',')p=NULL;else{p=(node*)malloc(sizeof(node));p->data=ch;p->lchild=creat(p->lch 阅读全文

posted @ 2012-01-05 16:17 ma6174 阅读(1084) 评论(0) 推荐(0) 编辑

数据结构实验二:栈和队列的基本操作和应用

摘要: 栈——进制的转换#include<iostream.h>#include<malloc.h>#include<stdlib.h>typedefstruct{int*base;int*top;intstacksize;}Stack;intInitStack(Stack&S){S.base=(int*)malloc(STACK_INIT_SIZE*sizeof(int));if(!S.base)exit(OVERFLOW);S.top=S.base;S.stacksize=STACK_INIT_SIZE;return1;}intPush(Stack&am 阅读全文

posted @ 2012-01-05 16:15 ma6174 阅读(3335) 评论(0) 推荐(0) 编辑

数据结构实验一:线性表的基本操作

摘要: 顺序表—线性表的顺序实现删除多余元素#include<iostream>#include<stdlib.h>usingnamespacestd;structnode{intn[100];intlength;inttag;}a;voidinit(){inti;for(i=0;i<30;i++){a.n[i]=rand()%10;a.length++;}}voiddisplay(intn){inti;for(i=0;i<n;i++)cout<<a.n[i]<<"";cout<<endl;}intfind(i 阅读全文

posted @ 2012-01-05 16:13 ma6174 阅读(1462) 评论(0) 推荐(0) 编辑

导航