`
hy2012_campus
  • 浏览: 29184 次
  • 性别: Icon_minigender_1
  • 来自: 河南
社区版块
存档分类
最新评论
文章列表
递归方式实现: public void coding(int[] b,int n){ if(n==0){ b[n]=0; outBn(b); b[n]=1; outBn(b); }else{ b[n]=0; outBn(b); b[n]=1; outBn(b); } } public void outBn(int[] b){ for(int i=0; i<b.length; i++){ System.out.println(b[i]); } System.out.println(); }   ...
public boolean bracketMatch(String str){ Stack<Integer> s = new Stack<Integer>(); for(int i = 0; i < str.length(); i++){ char c = str.charAt(i); switch(c){ case '{': case '[': case '(': s.push(Integer.valueOf(c));break; case '}': if(!s.isEmpty() ...
public void baseConversion(int i){ Stack<String> s = new Stack<String>(); while(i > 0){ s.push(i%8+""); i=i/8; } while(!s.isEmpty()){ System.out.print(s.pop()); } }  16进制转换为10进制: int HexToDec(char *s) { char *p = s; //空串返回0。 if(*p == '\0') re ...
public int[] merge(int[] a,int[] b){ int pa = pb = pc = 0; int m = a.length; int n = b.length; int[] c = new int[m+n]; while(pa < m && pb < n){ if(a[pa] < b[pb]){ c[pc++] = a[pa++]; }else{ c[pc++] = b[pb++]; } } if(pa < m){ while(pa < m){c[pc ...
来源于:http://www.java3z.com/cwbwebhome/article/article18/report92.html?id=4867 回文词是一种对称的字符串。任意给定一个字符串,通过插入若干字符,都可以变成回文词。现在的任务是,求出将给定字符串变成回文词所需要插入的最少字符数 。比如:“Ab3bd”插入2个字符后可以变成回文词“dAb3bAd”或“Adb3bdA”,但是插入少于2个的字符无法变成回文词。    [输入]:  第一行:字符串的长度N(3 <= N <= 5000)  第二行:需变成回文词的字符串  [输出]:  将给定字符串变成 ...
这是个汉诺塔程序,在调试的时候,输入的数字最好不要大于15,因为每大一个数所得的结果的步骤都会多一倍。如果你有耐心等待结果的话除外。汉诺塔是在欧洲流行的一种游戏,有a,b,c三个竿。a竿上有若干个由大到小的圆盘,大的在下面,小的在上面,b,c都是空杆,请你把a杆上的圆盘都倒到别的杆上,或b或c,在倒盘的过程中不可以大的压小的,实例程序如下: #include <stdio.h> #include <stdlib.h> void move(char x,char y) { printf("%c-->%c\n",x,y); } vo ...
整理与node.js开发指南 var http = require('http'); http.createServer(function(req,res){ res.writeHead(200,{'Content-Type':'text/html'}); res.write('<h1>node.js</h1>'); res.end('<p>hello world</p>'); }).listen(3000); console.log("http server is listenin ...
Global site tag (gtag.js) - Google Analytics