• 用cookie保存选择的选项

    2015-01-30
    每次刷新不会被重置啦 select name=sex id=sex onchange=save() option value=01 selected 男/opton option value=02 女/opton/selectinput id=s1 type=radio name=xueli value=0 onclick=save()/本科input id=s2 type=radio name=xueli value=1...
  • C语言二分查找(折半查找)代码

    2014-12-08
    #include stdio.h binarySearch(int a[], int n, int key){ int low = 0; int high = n - 1; while(low= high){ int mid = (low + high)/2; int midVal = a[mid]; if(midValkey) low = mid + 1; else if(midValkey) high = mid - 1; else return mid; } retur...
  • C语言顺序查找算法代码

    2014-12-07
    #include stdio.h#include stdlib.h#include memory.hint ordersearch(int a[], int n, int des){int i;for(i=0; in; i++)if(des==a[i])return 1;return 0;}int main(){int i, val;int a[8] = {32,12,56,78,76,45,43,98};int ret;for(i=0; i8; i++)printf(%d\...
  • C语言归并排序代码

    2014-12-05
    #include stdio.h #include stdlib.h #define N 7 void merge(int arr[], int low, int mid, int high){ int i, k; int *tmp = (int *)malloc((high-low+1)*sizeof(int)); //申请空间,使其大小为两个 int left_low = low; int left_high = mid;...
  • C语言快速排序代码

    2014-12-04
    #include stdio.h #include stdlib.h #define N 6 int partition(int arr[], int low, int high){ int key; key = arr[low]; while(lowhigh){ while(low high arr[high]= key ) high--; if(lowhigh) arr[low++] = arr[high]; while( lowhigh arr[low]=key ) l...
  • C语言插入排序代码

    2014-12-03
    #includestdio.h #includestdlib.h #define N 8 void insert_sort(int a[],int n); //插入排序实现,这里按从小到大排序 void insert_sort(int a[],int n)//n为数组a的元素个数 { //进行N-1轮插入过程 for(int i=1; in; i++) {...
  • C语言冒泡排序代码

    2014-12-02
    #includestdio.h#includestdlib.h#define N 8void bubble_sort(int a[],int n);//一般实现void bubble_sort(int a[],int n)//n为数组a的元素个数{//一定进行N-1轮比较for(int i=0; in-1; i++){//每一轮比较前n-1-i个,即已排序好...
  • C语言选择排序代码

    2014-12-01
    #includestdio.h#includestdlib.h#define N 8void select_sort(int a[],int n);//选择排序实现void select_sort(int a[],int n)//n为数组a的元素个数{//进行N-1轮选择for(int i=0; in-1; i++){int min_index = i;//找出第i小的数所在...
  • C语言打印n长度的等腰三角形

    2014-10-13
    #include stdio.hvoid main(){ int a,b,c,n,s=0; printf(请输入一个数:\n); scanf(%d,n); for(a=1;a=n;a++) { for(b=1;b=a-1;b++) { printf( ); } for(c=1;c=2*n+1-2*a;c++) { printf(*); s++; } printf(\n); } printf(\n总共%d个*号,s); }...
  • C语言打印菱形

    2014-09-26
    用for #include stdio.hvoid main(){ int a,b,c; //a为行 b为空格 c为* //打印前半部分 for(a=1;a=4;a++) { for(b=3;b=a;b--) { printf( ); } for(c=1;c=2*a-1;c++) { printf(*); } printf(\n); } //打印后半部分 for(a=1;a=3;a++) { for(b...
  • C语言打印乘法口诀表

    2014-09-26
    #include stdio.hvoid main(){ int x,y; y=1; while(y=9) { x=1; while(x=y) { printf(%d*%d=%d\t,x,y,x*y); x++; } printf(\n); y++; }} 用do-whlie #include stdio.hvoid main(){ int x,y; y=1; do { x=1; do { printf(%d*%d=%d\t,x,y,x*y); x++; }while(x...
  • 111条记录