`
soulwzy
  • 浏览: 14956 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
附图地址: http://www.docin.com/p1-532193843.html 在线玩网站: http://www.mathsisfun.com/games/towerofhanoi.html 定义:借助针——非目的地       目的针——目的地 只要遵循两个规则。从下往上数,偶数个盘片要去到借助针,奇数个盘片要去到目的针。 如图。 最初的思路:我们要让4去到借助针。3去到目的针。2去到借助针。1 去到目的针。 但移动了两步之后我们发现 这时候需要把借助针清空。才能让2去到借助针(Tower 2)。清空的方法是把Tower 2的盘片移动到Tower 3 。 之 ...
int readFile() { ifstream inFile("input.txt"); if (!inFile.is_open()) { cout << "infile opening error"; return 1; } int i = 0; while (!inFile.eof()) { inFile >> a[i++]; } n=i; inFile.close(); } void writeFile(int nn,int nnn ...
import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; /** * 厦门公交数据爬虫 * * @author Administrator * */ public class PaPA { static ...
1、java.util.Date类型转换成long类型 java.util.Date dt = new Date(); System.out.println(dt.toString()); //java.util.Date的含义 long lSysTime1 = dt.getTime() / 1000; //得到秒数,Date类型的getTime()返回毫秒数 2、由long类型转换成Date类型 SimpleDateFormat sdf= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //前面的lSysTime是秒 ...
#include <iostream> #include <string> using namespace std; class MyClass { private: string name; int id; int prefix; int value; public: MyClass() { }; MyClass(string n, int a, int p, int nm):name(n), id(a), prefix(p), value(nm){} // 利用初始化列表来初始化成员对象 friend ostre ...
查找最基本的类型 #include <iostream> #include <algorithm> #include <list> using namespace std; int main() { list<int> lst; lst.push_back(10); lst.push_back(20); lst.push_back(30); list<int>::iterator it = find(lst.begin(), lst.end(), 10); // 查找li ...

Boost::bind 测试代码

 
#include<boost/bind.hpp> #include<iostream> #include<vector> #include<algorithm> using namespace boost; using namespace std; struct point { int x,y; point(int a=0,int b=0):x(a),y(b){} void print(){ cout << "(" << x << ", ...
#include "boost/shared_ptr.hpp" #include <vector> #include <iostream> //boost的shared_ptr 是一种智能指针, //可以根据其被引用的次数进行智能释放,当被引用次数为0的时候自动释放, //这个功能和iphone上面编程,objective-c里的功能有所类似。 class shared { private: boost::shared_ptr<int> p ; //声明一个成员,智能指针p,我们将准备让它指向一 ...
#include <iostream> #include <string> #include <boost/program_options.hpp> using namespace std; int main(int argc, char* argv[]) { // using namespace boost::program_options; //声明需要的选项 namespace po = boost::program_options ; po::options_description desc(&q ...
#include <iostream> #include <string> #include <utility> #include <vector> #include "boost/any.hpp" class A { public: void some_function() { std::cout << "A::some_function()\n"; } }; class B { public: ...
VideoProject2ViewController.h // // VideoProject2ViewController.h // VideoProject2 // // Created by stu56 on 11-10-11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> @interface VideoProject2ViewController : UIViewController { IBOutl ...
.m文件 // // Test1AppDelegate.m // Test1 // // Created by stu42 on 11-9-23. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import "Test1AppDelegate.h" @implementation Test1AppDelegate @synthesize window; @synthesize slider; @synthesize field; - ...

快速排序

public class Qiicc { static int a[] = { 5, 4, 1, 2, 4, 5, 7, 8, 9 }; public static void main(String args[]) { qSort(0, a.length-1); for (int i = 0; i < a.length; i++) { System.out.print(a[i] + " "); } } public static void qSort(int low, int high) { ...
import java.util.Arrays; public class TestSort { /** * @param args */ static int [] a = {4324,3,3,24,32,43,43,4,24,2}; public static void main(String[] args) { Arrays.sort(a,0,a.length); for (int i = 0; i < a.length; i++) { System.out.pri ...
/** * 读取文件的函数 * * @param args */ public static boolean readFile() { try { Scanner input = new Scanner(new File("input.txt")); n = input.nextInt(); k = input.nextInt(); oil = n; nextOil = new int[k + 1]; for (int i = 0; i <= ...
Global site tag (gtag.js) - Google Analytics