ITeye博客

龙魂的代码库

soulwzy · 共 17 篇文章

汉诺塔玩法解密(非代码)

附图地址: 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 。 之后发现 这时候我们需要把towe…

2012-11-20 17:11 · 游戏攻略 · 评论(0)

输入输出c++

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) { ofstream outFile("output.txt"); outFile << nn << endl ; outFile << nnn <…

2012-10-15 20:58 · 零件代码 · c++ · 评论(0)

2b公交抓取程序,第一版(JAVA)

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 List<String> stationList…

2012-08-07 11:03 · 蛋疼自high · 评论(0)

JAVA里面的时间日期类的用法

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是秒数,先乘1000得到毫秒数,再转…

2012-08-07 10:57 · 零件代码 · 评论(0)

c++ 重载操作符(流输入输出)

#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 ostream &operator<<(ostream &stream, MyClas…

2012-07-10 13:53 · c++ · 评论(0)

std::find对容器内的东西进行查找,(查找基本类型,查找类类型)

查找最基本的类型 #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); // 查找list中是否有元素“10” if (it != lst.end()) // 找到了 如果找不到则代表it == lst.en…

2012-07-09 15:44 · c++ STL · 评论(0)

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 << "," << y << ")\n"; } void setX(int a){ cout << "setX:" << a << endl; } void setXY…

2012-07-09 15:32 · c++ Boost · 评论(0)

Boost::Shared_ptr初学

#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,我们将准备让它指向一个int型的空间 public: shared(boost::shared_ptr<int> p_…

2012-07-05 13:53 · c++ Boost · 评论(0)

测试Boost::program_options代码

#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("Allowed options"); desc.add_options() //运用桥接模…

2012-07-04 13:35 · c++ Boost · 评论(0)

初学boost::any的测试代码

#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: void some_function() { std::cout << "B::some_function()\n"; } }; void print_any(boost::any& a) { i…

2012-07-03 10:22 · c++ Boost · 评论(0)

【iphone】开发视频教程2里面的代码

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 { IBOutlet UISlider *slider ; IBOutle…

2011-10-12 10:48 · iphone · 评论(0)

内牛满面的iphone 入门实验源代码(objective c)

.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; -(IBAction) sliderChanged{ NSString *text =…

2011-10-10 10:02 · iphone · 评论(0)

快速排序

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) { if (low < high) { int pivot = partition(low, high)…

2011-06-05 22:19 · 零件代码 · 评论(0)

Arrays提供的自动排序

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.print(a[i] + " "); } } }

2011-06-05 22:16 · 零件代码 · 评论(0)

【输入输出】读取写入文件的常用代码

/** * 读取文件的函数 * * @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 <= k; i++) { nextOil[i] = input.nextInt(); } } catch (FileNotFoundException e)…

2011-05-02 18:42 · 零件代码 · 评论(0)