C++完美演繹 經典算法 如 /* 頭文件:my_Include.h */ #include <stdio.h> /* 展開C語言的內建函數指令 */ #define PI 3.1415926 /* 宏常量,在稍后章節再詳解 */ #define circle(radius) (PI*radius*radius) /* 宏函數,圓的面積 */ /* 將比較數值大小的函數寫在自編include文件內 */ int show_big_or_small (int a,int b,int c) { int tmp if (a>b) { tmp = a a = b b = tmp } if (b>c) { tmp = b b = c c = tmp } if (a>b) { tmp = a a = b b = tmp } printf("由小至大排序之后的結果:%d %d %d\n", a, b, c) } 程序執行結果: 由小至大排序之后的結果:1 2 3 可將內建函數的include文件展開在自編的include文件中 圓圈的面積是=201.0619264
標簽: my_Include include define 3.141
上傳時間: 2014-01-17
上傳用戶:epson850
一元稀疏多項式計算器[加法和乘法] 問題描述: 設計一元系數多項式計數器實現兩個多項式間的加法、減法。 基本要求: (1) 輸入并建立多項式 (2) 輸出多項式,輸出形式為整數序列:n,c1,e1,c2,e2……cn,en,其中n是多項式的項數,ci,ei分別為第i項的系數和指數。序列按指數降序排列。 (3) 多項式a和b相加,建立多項式a+b,輸出相加的多項式。 (4) 多項式a和b相減,建立多項式a-b,輸出相減的多項式。 用帶表頭結點的單鏈表存儲多項式。 測試數據: (1) (2x+5x8-3.1x11)+(7-5x8+11x9) (2) (6x-3-x+4.4x2-1.2x9)-(-6x-3+5.4x2+7.8x15) (3) (x+x2+x3)+0 (4) (x+x3)-(-x-x-3)
上傳時間: 2013-12-03
上傳用戶:561596
數字運算,判斷一個數是否接近素數 A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value. Given b (2 <= b <= 10) and a number in base b, determine whether it is a Niven number or not. Input Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone. Output For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise. Sample Input 10 111 2 110 10 123 6 1000 8 2314 0 Sample Output yes yes no yes no
上傳時間: 2015-05-21
上傳用戶:daguda
TIMER.ASM ********* [ milindhp@tifrvax.tifr.res.in ] Set Processor configuration word as = 0000 0000 1010 b. a] -MCLR tied to VDD (internally). b] Code protection off. c] WDT disabled. d] Internal RC oscillator [4 MHZ].
標簽: configuration Processor milindhp tifrvax
上傳時間: 2015-05-24
上傳用戶:wqxstar
c語言版的多項式曲線擬合。 用最小二乘法進行曲線擬合. 用p-1 次多項式進行擬合,p<= 10 x,y 的第0個域x[0],y[0],沒有用,有效數據從x[1],y[1] 開始 nNodeNum,有效數據節點的個數。 b,為輸出的多項式系數,b[i] 為b[i-1]次項。b[0],沒有用。 b,有10個元素ok。
上傳時間: 2014-01-12
上傳用戶:變形金剛
1問題描述: 設計一個實現稀疏多項式乘法的程序 2需求分析: 編程實現兩個一元多項式相乘,要求: 2.1輸入并建立多項式; 2.2輸出多項式,輸出形式為整數序列:n,c1,e1,c2,e2``````,cn.,en,其中n是多項式的系數,ci和ei分別是第i項的系數和指數,序列按指數降序排列。 2.3多項式a和b相乘,建立結果多項式a*b
上傳時間: 2015-08-15
上傳用戶:zhangliming420
黑白點的匹配貪心算法 設平面上分布著n個白點和n個黑點,每個點用一對坐標(x, y)表示。一個黑點b=(xb,yb)支配一個白點w=(xw, yw)當且僅當xb>=xw和yb>=yw。若黑點b支配白點w,則黑點b和白點w可匹配(可形成一個匹配對)。在一個黑點最多只能與一個白點匹配,一個白點最多只能與一個黑點匹配的前提下,求n個白點和n個黑點的最大匹配對數。
上傳時間: 2015-10-25
上傳用戶:zhliu007
古典密碼中,主要的思想為移位算法及置換算法。 1.移位密碼 密鑰K為整數,且取值空間為0到25;加密函數:x = x + k (mod 26);解密函數:x = x - k (mod 26)。當K=3時,為凱撒密碼。 2.仿射密碼 密鑰對由a、b組成,整數a滿足 gcd(a, 26) = 1,整數b的取值空間為0到25;加密函數:x = ax + b(mod 26);解密函數:x = a*y - a*b (mod 26)。當a=1,b=3時,為凱撒密碼。 3.維吉尼亞密碼 首先確定密鑰長度(本例中密鑰只采取個位數字,所以取決于輸入密鑰的長度),然后輸入滿足這個長度的向量;加密:取明文第一個字母并將之移k1位,這里k1=1,第二個字母移k2位,k2=2,一旦到了密鑰末尾,又從頭開始。 4.換位密碼 首先確定密鑰長度,輸入長度為5的0到4的整數序列,將明文分成每5個字母一組,每組字母按照密鑰進行換位。
標簽: 密碼
上傳時間: 2016-02-09
上傳用戶:jqy_china
編程題(15_01.c) 結構 struct student { long num char name[20] int score struct student *next } 鏈表練習: (1).編寫函數struct student * creat(int n),創建一個按學號升序排列的新鏈表,每個鏈表中的結點中 的學號、成績由鍵盤輸入,一共n個節點。 (2).編寫函數void print(struct student *head),輸出鏈表,格式每行一個結點,包括學號,姓名,分數。 (3).編寫函數struct student * merge(struct student *a,struct student *b), 將已知的a,b兩個鏈表 按學號升序合并,若學號相同則保留成績高的結點。 (4).編寫函數struct student * del(struct student *a,struct student *b),從a鏈表中刪除b鏈表中有 相同學號的那些結點。 (5).編寫main函數,調用函數creat建立2個鏈表a,b,用print輸出倆個鏈表;調用函數merge升序合并2個 鏈表,并輸出結果;調用函數del實現a-b,并輸出結果。 a: 20304,xxxx,75, 20311,yyyy,89 20303,zzzz,62 20307,aaaa,87 20320,bbbb,79 b: 20302,dddd,65 20301,cccc,99 20311,yyyy,87 20323,kkkk,88 20307,aaaa,92 20322,pppp,83
上傳時間: 2016-04-13
上傳用戶:zxc23456789
segment,一個簡單的中文分詞程序,命令行如下: java -jar segmenter.jar [-b|-g|-8|-s|-t] inputfile.txt -b Big5, -g GB2312, -8 UTF-8, -s simp. chars, -t trad. chars Segmented text will be saved to inputfile.txt.seg
上傳時間: 2014-01-04
上傳用戶:ynzfm