摘要: 用PHP来书写吧 $ar=array(1,2,3,4,5,......);$n=count($ar);for($i=0;$i<$n;$i++) for($j=0;$j<$n-1;$j++) //每次循环取 最大值或者最 小值 { $next=$j+1; if($ar[$j]>$ar[$next]){ //当前元素值 大于 下一个元素值,则替换 $t=$ar[$j]; $ar[$j]=$ar[$next]; $ar[$next]=$t; } }print_r($ar);//忧化算法for($i=0;$i<$n;$i++) for($j=$n-1;$j>=$i;$j- 阅读全文
posted @ 2011-08-14 21:22 solq 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include <stdlib.h> 3 struct tree{ 4 char info; 5 struct tree* left; 6 struct tree* right; 7 }; 8 struct tree* root; 9 struct tree* construct(struct tree* root,struct tree* insert,char info);10 void print(struct tree* root,int n);11 12 int main(int argc, char* 阅读全文
posted @ 2011-08-14 21:00 solq 阅读(295) 评论(0) 推荐(0) 编辑
摘要: #include "stdafx.h"#include <stdlib.h>int a,b,MAX;int* p;int *top,*foot;int push(int n) //压栈操作{ if(p>foot) { printf("overflow max"); return -1; } *p=n; p++; return 1;}int pop() //出栈操作{ p--; if(p<top) { printf("overflow min\n"); return -1; } return *p;}int ma 阅读全文
posted @ 2011-08-14 19:14 solq 阅读(228) 评论(0) 推荐(0) 编辑
摘要: #include <stdlib.h>#include <stdio.h>struct test{ int value; struct test *next;};struct test* create(){ //创建create 函数,返回 struct test* 结构指针 返回的是头部指针 test *head,*tail,*p; head=tail=NULL; //head 是保存头部指针,p是当前指针,tail是临时替换的指针,是用来过度的 int i; for(int j=0;j<4;j++) { scanf("%d",&i) 阅读全文
posted @ 2011-08-14 18:22 solq 阅读(336) 评论(0) 推荐(0) 编辑
摘要: #include <stdlib.h>#include <stdio.h>struct test{ int value; struct test *next;};struct test* create(){ //创建create 函数,返回 struct test* 结构指针 返回的是头部指针 test *head,*tail,*p; head=tail=NULL; //head 是保存头部指针,p是当前指针,tail是临时替换的指针,是用来过度的 int i; while(scanf("%d",&i)==1) { //(数据类型)mallo 阅读全文
posted @ 2011-08-14 16:51 solq 阅读(368) 评论(0) 推荐(0) 编辑