函數對象的應用:在指定的檔案中顯示指定長度的字串

#include<iostream>#include<vector>#include<string>#include<fstream>#include<sstream>#include<functional>#include<algorithm> using namespace std; class EQ_Len{private:    string::size_typebound;public:   

Dijkstra最短路徑求解(不考慮權值為負的情況)

#include<iostream>#include<vector>#include<set>#include<stack>#include<stdlib.h>using namespace std;const int MaxNumber=1e10;struct EdgeType //邊的類型{ int fromvertex; //邊的起點 int tovertex;  //邊的終點 double weight;

經典單例模式及測試

public class ClassicSingleton {private static ClassicSingleton instance=new ClassicSingleton();private ClassicSingleton() {}public static ClassicSingleton getInstance() {return instance;}}import java.util.logging.Logger;import junit.framework.Assert;

簡單文字查詢程式

 #include<iostream>#include<fstream>#include<vector>#include<string>#include<set>#include<map>#include<sstream> using namespace std; //功能實現://輸入要尋找的檔案名稱和要尋找的單詞,顯示該單詞在檔案中每一行出現的次數,行號按升序排列//文字查詢類class TextQuery{

Bellman-ford演算法應對有向圖中有權值為負的情況下求最短路徑

#include<iostream>#include<vector>#include<set>#include<stack>#include<stdlib.h>using namespace std;const int MaxNumber=1e10;struct EdgeType //邊的類型{ int fromvertex; //邊的起點 int tovertex; //邊的終點 double weight;

圖的應用–二部圖的判定及利用匈牙利演算法求二部圖的最大匹配

1. 圖類#ifndef GRAPH_H#define GRAPH_Hconst int maxvertex=100; //最多可以有100個頂點const int maxedge=1000; //最多可以有1000條邊const double maxweight=1e10; //權值最大值#include <iostream>#include <cstdlib>#include <memory>using namespace

最短路徑多源點Flod-Warshall演算法

#include<iostream>#include<vector>#include<set>#include<stack>#include<stdlib.h>using namespace std;const int MaxNumber=1e10;struct EdgeType //邊的類型{ int fromvertex; //邊的起點 int tovertex; //邊的終點 double weight;

簡易隨機數發生器

代碼: /*This is a free Program, You can modify or redistribute it under the terms of GNU*Description: 隨機數發生器,指定一個數,比如1000,要求隨機產生1到1000之間的 任意數,並且1到1000之間任何一個數產生的機率是相等的,都是1/1000*Language: C++*Development Environment: VC6.0*Author:

差限問題求解利用Bell-ford演算法構造差限圖通過最短路徑求解

#include<iostream>#include<vector>#include<set>#include<stack>#include<stdlib.h>using namespace std;const int MaxNumber=1e10;struct EdgeType //邊的類型{ int fromvertex; //邊的起點 int tovertex; //邊的終點 double weight;

最大子矩陣和問題

 #include<iostream>using namespace std;//給定一個矩陣a(0...m-1,0...n-1),求出它的一個子矩陣b(i1...i2,j1...j2),使得b的所有元素和最大void MaxSum(int **a,int m,int n,int &besti1,int &besti2,int &bestj1,int &bestj2,int &sum){ int b; int i1,i2,j1,j2; int

備忘錄模式的探討

1.代碼/*This is a free Program, You can modify or redistribute it under the terms of GNU*Description:一個簡單的備忘錄模式*備忘錄模式: http://baike.baidu.com/view/3591132.htm*Language: Java*Development Environment: Eclipse*Author: Wangzhicheng*E-mail:

完美數的判斷

#include<iostream>#include<vector>#include<cmath>using namespace std;class Integer{private: long num; vector<int>divisor; //num的真約數放在向量divisor中public: Integer(long n=0):num(n) { } int Sum(long n); //求整數各個位的數的累加和 inline int

最優三角剖分

 #include<iostream>#include<math.h>using namespace std;//輸入多邊形的頂點(二維)序列,構造最優的三角剖分,所謂最優三角剖分是指n個頂點的凸多邊形,從任何頂點向它不相鄰的頂點連線//可以構成n-2個三角形,n個頂點可以構成n(n-2)個三角形//三角形的邊上的權值是邊上兩個鄰接點的歐式距離,找出這n(n-2)個三角形權值最小的那n-2組const double Max=1000000;double distance(

利用快速排序從大量資料中尋找最大的若干個資料

/*This is a free Program, You can modify or redistribute it under the terms of GNU*Description:在大量資料中尋找最大的若干個資料*Language: C++*Development Environment: VC6.0*Author: Wangzhicheng*E-mail: 2363702560@qq.com*Date:

求子數組的最大和問題–一道浙江大學考研壓軸題(被Google拿來做面試題)

一 問題:輸入一組資料,有正數和負數,數組中連續的一個或多個整數組成一個子數組,每個子數組都有一個和。求所有子數組的和的最大值。要求時間複雜度為O(n)。 二 解題思路:本題不能採用枚舉法,因為題目要求時間複雜度為O(n)。現在先舉一個例子有一組資料,共12個,它們是:-2  3  -1  3  -6  7  8  -1  10  -20  -11  18通過手算和觀察,最大和是24,這個子數組是:7  8  -1  10我們現在設三個變數max  sum   a[i],max表示子數組最大和,

一道baidu海量尋找題

問題描述:現在有上億個浮點數,設計演算法從中找到最大的10000個資料解題思路:1. 一般來說,這上億個浮點數可以放在一個文字檔中,我們把這些資料進行分塊處理,比如分為10塊,每塊資料量相對較少,可以裝入記憶體2. 將1000萬個資料裝入記憶體後,按照快速排序的方法從中尋找最大的10000個資料,依次處理其餘的9塊,都找到每一塊的最大的10000個資料3.

百度一道面試題–在一顆二叉排序樹中尋找和為某一值的所有路徑

一 問題描述:輸入一個整數和一棵二元樹。從樹的根結點開始往下訪問一直到葉結點所經過的所有結點形成一條路徑。列印出和與輸入整數相等的所有路徑。,輸入整數70 和如下二叉排序樹輸出為:30 15 25二 解題思路:利用二叉樹的前序走訪,注意:路徑是從根到葉子的所有節點的序列三: 代碼/*This is a free Program, You can modify or redistribute it under the terms of

觀察者模式的簡單應用

一 觀察者模式定義對象間的一種一對多的依賴關係,當一個對象的狀態發生改變時,所有依賴於它的對象都得到通知並被自動更新。二 Java執行個體package PostOfficeInstance;public interface ISubscribe {public void registered(Postoffice postoffice);public void unregistered(Postoffice postoffice);public void

一種尋找k個最小元素的方法

/*This is a free Program, You can modify or redistribute it under the terms of GNU*Description:一種尋找k個最小元素的方法*Language: C++*Development Environment: VC6.0*Author: Wangzhicheng*E-mail: 2363702560@qq.com*Date: 2012/11/25*/#include

組合模式的簡單應用

public abstract class Component {protected String name;protected String type;protected void setType(String type) {this.type=type;}protected final String getType() {return type;}protected void setName(String name) {this.name=name;}protected final

總頁數: 61357 1 .... 15847 15848 15849 15850 15851 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.