[改訂新版]C言語による標準アルゴリズム事典

Similar documents
Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

C39N410.dvi

C/C++ - 文件IO

プログラムの設計と実現II

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

_汪_文前新ok[3.1].doc

新・明解C言語入門編『索引』

C 1

新版 明解C言語入門編

C/C++ - 函数

新・解きながら学ぶC言語

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

C/C++ - 字符输入输出和字符确认

C

第3章.doc

untitled

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

untitled

Microsoft Word - 095_ 什麼最快樂 (白話與經文加註)-ok .doc

Microsoft Word - PKUCS计算机教育 doc

C/C++程序设计 - 字符串与格式化输入/输出

名人养生.doc

常见病防治(二).doc

C++ 程式設計

untitled

封面.PDF

关于2007年硕士研究生培养方案修订几点要求的说明


ACM

C

論鄭玄對《禮記‧月令》的考辨

Microsoft Word - 考试大纲 (2)

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

GOLD(General Ontology for Linguistic Description) (,) (,) (,) () () (,) () (,) (,) (,)

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

C/C++语言 - 运算符、表达式和语句

epub 33-8

CC213

FY.DOC

III

未命名-2

C语言的应用.PDF

Policy Agenda

糖尿病防治指南(二).doc

C C

chap07.key

Microsoft Word - chap13.doc

ebook 145-6

肝病养生.doc

C/C++ - 字符串与字符串函数

大学计算机基础B.doc

Welch & Bishop, [Kalman60] [Maybeck79] [Sorenson70] [Gelb74, Grewal93, Maybeck79, Lewis86, Brown92, Jacobs93] x R n x k = Ax k 1 + Bu k 1 + w

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 计 算 机 应 用 基 础 刘 升 贵 年 8 月

Microsoft Word 选课手册.doc

nooog

EC( )18 第 2 頁 (c) 刪 除 以 下 常 額 職 位 2 個 顧 問 醫 生 職 位 第 4 / 第 3 / 第 2 點 ) ( 145,150 元 至 149,600 元 /127,900 元 至 135,550 元 /113,520 元 至 120,553 元 ) (

sp_overview.pptx

标题

XXX专业本科人才培养方案

untitled

C/C++ 语言 - 循环

49274h1.pdf

C/C++语言 - C/C++数据

附件2

复 变 函 数 与 积 分 变 换 常 微 分 方 程 数 值 分 析 数 值 分 析 课 程 实 习 微 分 方 程 数 值

中医疗法(上).doc

中国科学技术大学学位论文模板示例文档

SuperMap 系列产品介绍

untitled

untitled

Microsoft Word - CPE考生使用手冊 docx

第二章 影響中共與越南關係發展的主要原因

( ) / ISBN /D ( )

经典案例(三)

L A TEX 2000 Tang 2

信息安全概论第二讲 密码学-new.ppt

CC213

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446>

教 师 介 绍 教 师 : 吴 永 辉 博 士 副 教 授 简 历 : 上 海 科 技 大 学 计 算 机 系 本 科 复 旦 大 学 计 算 机 系 硕 士 华 东 师 范 大 学 计 算 机 系 工 作 复 旦 大

C


CSSCI

CC213

威 福 髮 藝 店 桃 園 市 蘆 竹 區 中 山 里 福 祿 一 街 48 號 地 下 一 樓 50,000 獨 資 李 依 純 105/04/06 府 經 登 字 第 號 宏 品 餐 飲 桃 園 市 桃 園 區 信 光 里 民

南華大學數位論文

(1) C

新版 明解C++入門編

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

C6_ppt.PDF


No

二零一零至一一年施政报告 - 施政纲领

Microsoft PowerPoint - plan06.ppt

資訊戰與數位鑑識

*33*!!! "!! #$! %#! "& "! #! %! # ( ) * # +, # -, # +., $ /# ( ) 0 $ +# ( ) 0 $.# ( ) 0 $ # $! % "" " % 1 % & ( * ) * % " " %.! % 2!!"+# ( "&! " ( "#

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

untitled

( CIP ) /. - :, ( ) ISBN C CIP ( 2005 ) ( 1 : ) : / : ISB

心理障碍防治(下).doc

Transcription:

iii C 1991 SEND + MORE = MONEY C 100 2003 Java 2003 27 PC-9800 C BMP SVG EPS BMPSVG WindowsMacLinux Web

iv int main() int main(void) EXIT_SUCCESS 0 https://github.com/okumuralab/ algo-c TEX TEX PDF PDF CTP Computer Modern Palatino Inconsolata 2018 3 28

v AZ a[0..n-1] a[0] a[n-1] \ Y= (1101) 2 2 1101 O(n 2 ) n 2 O x x C floor(x) x x C ceil(x) : 3.14 = 3 3.14 = 4 x mod y x y : 8 3 2 8 mod 3 = 2 max(... ) min(... ) : max(35, 97, 12) = 97min(35, 97, 12) = 12

1 exchange of values ab a = b; b = a; /*! */ temp temp = a; a = b; b = temp; b ^= a; a ^= b; b ^= a; a a = 0 (a b) c = a (b c) b = a - b; a -= b; b += a; b = 0 b = a / b; a /= b; b *= a; RubyPythonJulia a,b = b,a swap.c swap(&x, &y); & int xy 1 void swap(int *x, int *y) 2 { 3 int temp; 4 5 temp = *x; *x = *y; *y = temp; 6 } error detecting code 97 1

2 96/97 97 0 [4] Luhn 10 1000... 2 10 9 2 18 1 + 8 = 9 9 9 18 9 = 9 Damm [5] ISBN CRC luhn.c Luhn 1 #include <stdio.h> 2 #include <string.h> 3 4 int main(void) 5 { 6 char *s = "5555555555554444"; /* */ 7 int i, d, w = 1, t = 0; 8 9 for (i = strlen(s) - 1; i >= 0; i--) { 10 d = w * (s[i] - '0'); 11 if (d > 9) d -= 9; 12 t += d; 13 w = 3 - w; 14 } 15 if (t % 10 == 0) printf("\n"); else printf("\n"); 16 return 0; 17 } [1] Benjamin Arazi. A Commonsense Approach to the Theory of Error Correcting Codes. MIT Press, 1988. [2] Richard W. Hamming. Coding and Information Theory. Prentice Hall, second edition 1986. [3] W. Wesley Peterson and E. J. Weldon, Jr. Error-Correcting Codes. MIT Press, second edition 1972. [4] W. Wesley Peterson. Communications of the ACM, 34(12): 110 113, December 1991. [5] H. Michael Damm. Discrete Mathematics, 307(6): 715 729 (2007).

3 algorithm 9 al-khwārizmī cryptosystem plaintext encrypt encryption ciphertext decrypt decryption cryptanalyze cryptanalysis CaesarCaesar cipher IBM 1 HAL +7 PIT Caesar 3 key Caesar k while ((c = getchar())!= EOF) putchar(c ^ k); 2 c k k = c 256 1 k k (k c) = c 2 0x20 0x7E while ((c = getchar())!= EOF) putchar((k + 0x7E - c) % 0x5F + 0x20); DESData Encryption Standard FEAL [4] AESAdvanced Encryption StandardNTT Camellia

4 [1 4] [5 7] GnuPG gpg crypt.c crypt foo bar 12345 foo bar 12345 1 bar 12345 foo 0 255 RAND_MAX + 1 256 16 18 1 #include <stdio.h> 2 #include <stdlib.h> 3 int main(int argc, char *argv[]) 4 { 5 int c, r; 6 FILE *infile, *outfile; 7 8 if (argc < 3 argc > 4 9 (infile = fopen(argv[1], "rb")) == NULL 10 (outfile = fopen(argv[2], "wb")) == NULL) { 11 fputs(": crypt infile outfile [key]\n", stderr); 12 return 1; 13 } 14 if (argc == 4) srand(atoi(argv[3])); 15 while ((c = getc(infile))!= EOF) { 16 do { 17 r = rand() / ((RAND_MAX + 1U) / 256); 18 } while (r >= 256); 19 putc(c ^ r, outfile); 20 } 21 return 0; 22 } [1] Jennifer Seberry and Josef Pieprzyk. Cryptography: An Introduction to Computer Security. Prentice Hall, 1989.

5 [2] William H. Press, Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling. Numerical Recipes in C: The Art of Scientific Computing. Cambridge University Press, 1988. 228 236 2 1992 Numerical Recipes in C 1993 [3] Al Stevens. DES Revisited and the Shaft. Dr. Dobb s Journal, November 1990, 149 153, 164 166. [4] 1990DES FEAL [5] Bruce Schneier. Applied Cryptography. Wiley, 1993. 2015 [6] 3 SB 2015 [7] 2015https: //herumi.github.io/ango/ stable marriage problem N N M 1 F 1 M 2 F 2 M 1 F 1 F 2 F 2 M 2 M 1 1 2 O(N 2 ) Gale Shapley Shapley 2012

6 marriage.c N N N 2N N 1,..., N N = 3 2 3 1 1 2 > 3 > 1 2 1 3 2 2 > 1 > 3 3 2 1 3 3 > 2 > 1 1 3 2 1 1 > 3 > 2 2 3 1 2 2 > 3 > 1 3 1 2 3 3 > 1 > 2 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define N 3 /* */ 4 int boy[n+1], girl[n+1][n+1], position[n+1], rank[n+1][n+1]; 5 6 int main(void) 7 { 8 int b, g, r, s, t; 9 10 for (g = 1; g <= N; g++) { /* */ 11 for (r = 1; r <= N; r++) { 12 scanf("%d", &b); rank[g][b] = r; 13 } 14 boy[g] = 0; rank[g][0] = N + 1; /* */ 15 } 16 for (b = 1; b <= N; b++) { /* */ 17 for (r = 1; r <= N; r++) scanf("%d", &girl[b][r]); 18 position[b] = 0; 19 } 20 for (b = 1; b <= N; b++) { 21 s = b; 22 while (s!= 0) { 23 g = girl[s][++position[s]]; 24 if (rank[g][s] < rank[g][boy[g]]) { 25 t = boy[g]; boy[g] = s; s = t; 26 } 27 } 28 } 29 for (g = 1; g <= N; g++) printf(" %d - %d\n", g, boy[g]); 30 return 0; 31 } [1] Dan Gusfield and Robert W. Irving. The Stable Marriage Problem: Structure and Algorithms. MIT Press, 1989. [2] Donald E. Knuth. Mariages stables et leurs relations avec d autres problèmes combinatoires: Introduction à l analyse mathématique des algorithmes. Les Presses de l Université de Montréal, 1976.

7 [3] Robert Sedgewick. Algorithms. Addison Wesley, second edition 1988. 499 504 Pascal C C++ Java fourth edition 2011 Kevin Wayne [4] Niklaus Wirth 1979168 176