算法實(shí)現(xiàn)題1-5 最大間隙問題 « 問題描述: 最大間隙問題:給定n 個(gè)實(shí)數(shù)x , , xn 1 2 ,求這n 個(gè)數(shù)在實(shí)軸上相鄰2 個(gè)數(shù)之間的最 大差值。假設(shè)對(duì)任何實(shí)數(shù)的下取整函數(shù)耗時(shí)O(1),設(shè)計(jì)解最大間隙問題的線性時(shí)間算法。 « 編程任務(wù): 對(duì)于給定的n 個(gè)實(shí)數(shù)n x , x , , x 1 2 ,編程計(jì)算它們的最大間隙。 « 數(shù)據(jù)輸入: 輸入數(shù)據(jù)由文件名為input.txt的文本文件提供。文件的第1 行有1 個(gè)正整數(shù)n。接下來 的1 行中有n個(gè)實(shí)數(shù)n x , x , , x 1 2 。 « 結(jié)果輸出: 程序運(yùn)行結(jié)束時(shí),將找到的最大間隙輸出到文件output.txt中。 輸入文件示例 輸出文件示例 input.txt 5 2.3 3.1 7.5 1.5 6.3 output.txt 3.2
上傳時(shí)間: 2016-05-28
上傳用戶:咔樂塢
Ex4-22 單射函數(shù)問題 « 問題描述: 設(shè)函數(shù)f將點(diǎn)集S = {0,1, , n -1}映射為f (S) = { f (i) | iÎ S} Í S 。單射函數(shù)問題要 從S中選取最大子集X Í S 使f (X )是單射函數(shù)。 例如,當(dāng)n=7, f (S) = {1,0,0,2,2,3,6} Í S 時(shí), X = {0,1,6} Í S 是所求的最大子集。 « 編程任務(wù): 對(duì)于給定的點(diǎn)集S = {0,1, , n -1}上函數(shù)f,試用抽象數(shù)據(jù)類型隊(duì)列,設(shè)計(jì)一個(gè)O(n)時(shí) 間算法,計(jì)算f的最大單射子集。 « 數(shù)據(jù)輸入: 由文件input.txt 提供輸入數(shù)據(jù)。文件的第1 行有1 個(gè)正整數(shù)n,表示給定的點(diǎn)集 S = {0,1, , n -1}。第2 行是f (i)的值,0 £ i < n。 « 結(jié)果輸出: 程序運(yùn)行結(jié)束時(shí),將計(jì)算出的f的最大單射子集的大小輸出到output.txt中。 輸入文件示例 輸出文件示例 input.txt 7 1 0 0 2 2 3 6 output.txt 3
標(biāo)簽: Iacute 61516 laquo Icirc
上傳時(shí)間: 2016-05-28
上傳用戶:tyler
This document including C language project file organization, C language trap and flaw, C language programming precious book three parts.
標(biāo)簽: language organization including document
上傳時(shí)間: 2016-05-28
上傳用戶:tfyt
不用說的好,我們室主任開發(fā)的Photonics cyrestal band gap計(jì)算Fortran代碼。注意不要忘了input文本。
標(biāo)簽:
上傳時(shí)間: 2014-01-23
上傳用戶:jcljkh
Tasks Read the textbook about the details of Vigenére Cipher. Implement the algorithm by C or C++. Requirements You do this lab in a group of two students. Your program should have input and output as follows: csci>a.out --> Please input the key: receptive --> Please input the plain text: wearediscoveredsaveyourself --> The cipher text is : nicvtwqngfzgvtwavzvcqyglmgj -->The original message is: wearediscoveredsaveyourself • You should test your program with several runs.
標(biāo)簽: the Implement algorithm textbook
上傳時(shí)間: 2013-12-21
上傳用戶:bruce5996
% DYNMODES calculates ocean dynamic vertical modes % taking a column vector of Brunt-Vaisala values (Nsq) at % different pressures (p) and calculating some number of % dynamic modes (nmodes). % Note: The input pressures need not be uniformly spaced, % and the deepest pressure is assumed to be the bottom.
標(biāo)簽: Brunt-Vaisala calculates DYNMODES vertical
上傳時(shí)間: 2013-12-06
上傳用戶:busterman
This guide reviews the rules and syntax of the principle commands that comprise C and its object-oriented cousin, C++. The reference consists of 19 chapters that define operators and the standard input/output, string, character, and more.
標(biāo)簽: object-ori and principle the
上傳時(shí)間: 2014-01-15
上傳用戶:ve3344
The CoinUtils project is a collection of open-source utilities developed and used by a variety of other projects in the COIN-OR repository. The project includes classes for storing and manipulating sparse matrices and vectors, performing matrix factorization, parsing input files in standard formats, building representations of mathematical programs, comparing floating point numbers with a tolerance, performing simple presolve operations, and warm starting algorithms for mathematical programs, among others.
標(biāo)簽: open-source collection CoinUtils developed
上傳時(shí)間: 2013-12-19
上傳用戶:xmsmh
ACM Programming contest activity at Stony Brook is sponsored by a grant from Salomon Smith Barney. In the 2002 Greater New York Regional, Stony Brook s teams finished 2nd and 5th with 54 teams competing! In the 2003 Greater New York Regional, Stony Brook finished 4th of 60 teams. In the 2004 Greater New York Regional, three of Stony Brook s teams finished in the top 15 positions!
標(biāo)簽: Programming sponsored activity contest
上傳時(shí)間: 2013-12-13
上傳用戶:wff
Description 為了宣傳本次“網(wǎng)宿科技杯”廈門大學(xué)第五屆程序設(shè)計(jì)競(jìng)賽,系里面做了兩張精美的海報(bào)。經(jīng)過了精確的計(jì)算,為了達(dá)到最佳美觀效果,每張海報(bào)都有自己最佳的粘貼位置。但是現(xiàn)在問題是,如果兩張海報(bào)都要求貼在最佳位置時(shí),很有可能有部分地方會(huì)重疊在一起。現(xiàn)在您來判斷一下這兩張海報(bào)是否重疊。 Input 輸入包含兩行,每一行有四個(gè)整數(shù)來描述這個(gè)海報(bào)的最佳粘貼位置,X,Y,W,H(-10000<= X,Y <= 10000)(0 < W, H <= 10000),X,Y表示海報(bào)左下角的坐標(biāo),W,H分別表示寬度和高度。 Output 輸出"Yes"表示兩張海報(bào)互相重疊(表示存在一個(gè)面積大于0的公共區(qū)域),否則輸出"No"。(不包含引號(hào),注意大小寫) Sample Input -10 -10 20 30 0 0 30 20 Sample Output Yes
標(biāo)簽: Description 大學(xué) 程序設(shè)計(jì) 競(jìng)賽
上傳時(shí)間: 2016-06-26
上傳用戶:gxf2016
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1