ohp11.dvi
|
|
- えの しばもと
- 4 years ago
- Views:
Transcription
1 19 11 ( )
2 / ( ) n O(n 2 ) O(n 2 ) ( ) 1 d n 1 n logn O(nlogn) n ( n logn C ) 2
3 ( ) ( merge) : 2 ivec merge 3
4 ( ) (2) int *ivec_new(int size) { int *a = (int*)malloc((size+1) * sizeof(int)); a[0] = size; return a; int *ivec_merge(int *b, int *c) { int ib = 1, ic = 1, ia = 1, *a = ivec_new(b[0]+c[0]); while(ia <= a[0]) { if(ib > b[0]) { a[ia++] = c[ic++]; else if(ic > c[0]) { a[ia++] = b[ib++]; else if(c[ic] < b[ib]) { a[ia++] = c[ic++]; else { a[ia++] = b[ib++]; return a; 4
5 ( ) (3) 2 a ia a ib ic b c ( 1) a b c ( ) c b ( ) 2 ( ) a ( ) a 5
6 1 1 ( 1 ) 2 2 deq 1 enq enq deq x : 1 1 6
7 (2) // mergesort1 --- merge sort unsing queue #include <stdlib.h> #include "pqueue.h" (ivec_new, ivec_merge ) void mergesort1(int *a, int n) { pqueuep q = pqueue_new(n+1); int *v, *w; for(int i = 0; i < n; ++i) { v = ivec_new(1); v[1] = a[i]; pqueue_enq(q, v); while(true) { v = (int*)pqueue_deq(q); if(pqueue_isempty(q)) { break; w = (int*)pqueue_deq(q); pqueue_enq(q, ivec_merge(v, w)); free(v); free(w); for(int i = 0; i < n; ++i) { a[i] = v[i+1]; 7
8 (3) ( ) ( ) ( ) n 1 enq 2 deq ( 2 free) 1 8
9 (4) 1 ( ) ( pstack) expect sort iarray ( ) 2 1 ( ) 9
10 1 n n 2 10
11 (2) // mergesort2 --- merge sort with recuresive division #include <stdlib.h> (merge ) static void ms(int *a, int i, int j, int *b) { if(i >= j) { return; int k = (i + j) / 2; ms(a, i, k, b); ms(a, k+1, j, b); merge(b, a+i, k-i+1, a+k+1, j-k); for(k = 0; k < j-i+1; ++k) { a[i+k] = b[k]; void mergesort2(int *a, int n) { int *b = (int*)malloc(n * sizeof(int)); ms(a, 0, n-1, b); free(b); 11
12 (3) mergesort2 ms ms ms (i j ) b 1 k i k k+1 j a+i a+k+1 b a 3 merge ( ) 12
13 2 ( ) 2 1 ( 3 ) p (partition) ( ) p p p ( 3 ) (quick sort) p merge sort quick sort p sorted sorted partition merge x < p p x > p sorted sorted p sorted 3: 13
14 (2) quicksort qs p // quicksort --- quick sort with recuresive division static void iswap(int *a, int i, int j) { int x = a[i]; a[i] = a[j]; a[j] = x; void qs(int *a, int i, int j) { if(j <= i) { return; int s = i, pivot = a[j]; for(int k = i; k < j; ++k) { if(a[k] < pivot) { iswap(a, s++, k); iswap(a, j, s); qs(a, i, s-1); qs(a, s+1, j); void quicksort(int *a, int n) { qs(a, 0, n-1); 14
15 (3) s p k p s s 1 p s s p p ( ) 4 ( ) ( ) ( : ) 15
16 (bogo sort) 5 (10 ) ( ) 6 ( ) 16
17 2 2 (tree) ( ) (root) (node) ( ) (parent) (child) ( ) 0 (leaf) 2 (binary tree) 3 (N-ary tree) 2 17
18 2 (2) 2 (full binary tree) 2 (complete binary tree) (1) 2 ( 2 n 1 ) (2) N 2 4 ( 2 1 ) N-ary tree root binary tree full binary tree complete binary tree (1) complete binary tree (2) (array rep.) leaf : 2 18
19 2 (3) 2 (2) 0 i( i) 2i + 1 2i + 2 ( i (i 1)/2 ) C 0 1 2i 2i+1 i/2 19
20 2 (heap) malloc 1 (maximum heap) ( ) ( ) (heap sort) 1 ( ) logn 20
21 2 (2) 5 8 ( 5 ) ? : 21
22 2 (3) 8 2 ( ) 8 OK ( 5 ) 8 (pushdown) n 2 ( ) log 2 n logn O(nlogn) 22
23 2 (4) 1 ( ) OK n logn O(nlogn) 23
24 P L R define i iswap k if 1 k (k ) ( ) k k 24
25 (2) // heapsort1 --- heap sort using balanced bin-tree #define P(i) ((i-1)/2) #define L(i) (2*i+1) #define R(i) (2*i+2) static void iswap(int *a, int i, int j) { int x = a[i]; a[i] = a[j]; a[j] = x; void pd(int *a, int i, int j) { for(int k = L(i); k <= j; ) { if(k < j && a[k] < a[k+1]) { ++k; if(a[p(k)] >= a[k]) { break; iswap(a, P(k), k); k = L(k); void heapsort1(int *a, int n) { 25
26 for(int i = n-1; i >= 0; --i) { pd(a, i, n-1); for(int i = n-1; i > 0; --i) { iswap(a, 0, i); pd(a, 0, i-1); 1 ( ) 26
27 (3) 7 maxbuf ( ) n n ( ) 1 2 ( ) (push up) 27
28 ? option 2 2 _0_ ( ) q l r p / x s m ( ) 28
29 ? option(2) s % gcc8 heapgame.c -lncurses %./a.out 7 29
30 ? option(3) // heapgame.c --- construct heap and remove max screen game. #include <stdio.h> #include <stdbool.h> #include <ncurses.h> #include <stdlib.h> #include <time.h> #define P(i) ((i-1)/2) #define L(i) (2*i+1) #define R(i) (2*i+2) #define MAXARR 128 static int a[maxarr]; static int max, cur = 0; static void pos(int n, int *x, int *y) { int y1 = 0, x1 = 0; 30
31 for(int i = 1; i <= n; ++i) { if(i==1 i==3 i==7 i==15 i==31 i==63) { ++y1; x1 = 0; else { ++x1; *x = x1; *y = y1; static void upd() { char buf[10]; int x, y; for(int i = 0; i < max; ++i) { pos(i, &x, &y); move(y*2+1, x*3+1); sprintf(buf, "%3d", a[i]); addstr(buf); pos(cur, &x, &y); move(y*2+1, x*3+3); void iswap(int *a, int i, int j) { int x = a[i]; a[i] = a[j]; a[j] = x; void shuffle(int *a, int size) { 31
32 for(int i = 0; i < size; ++i) { iswap(a, i, rand()%(size-i)); bool checkheap(int *a, int size) { for(int i = 1; i < size; ++i) { if(a[p(i)] < a[i]) { return false; return true; int main(int argc, char *argv[]) { max = atoi(argv[1]); if(max > MAXARR) { max = MAXARR; for(int i = 0; i < max; ++i) { a[i] = i; srand(time(null)); initscr(); noecho(); cbreak(); system("stty raw"); clear(); while(true) { upd(); refresh(); int ch = getch(); switch(ch) { case q : endwin(); return 0; // quit case p : if(cur > 0) { cur = P(cur); break; // parent case l : if(l(cur) < max) { cur = L(cur); break; // left-child 32
33 case r : if(r(cur) < max) { cur = R(cur); break; // right-chlid case x : if(cur > 0) { iswap(a, cur, P(cur)); break; // excange case s : shuffle(a, max); break; // shuffle case m : char *msg = "NG"; // move top elt if(max <= 1) { msg = "GOAL!"; else if(checkheap(a, max)) { iswap(a, 0, max-1); --max; msg = "MOVED"; cur = 0; clear(); move(15, 5); addstr(msg); clrtoeol(); break; default: break; 33
34 ? option(4) 8 a. b. ( ) c. ( ncurses getch timeout ) d. ncurses 34
35 6 ( ) stable non-stable 6: ( ) 35
36 (2) (unsigned short ) struct sortval { unsigned short key, seq; ; key seq 9 ( ) 36
37 11A ( 23:59 ) 1. sol CED /home3/staff/ka002689/prog19upload 11a 2. ( ( ) ( ) 5. Q1. Q2. Q3. ( ) 37
38 11B : B 11B A 11B ( 11A ) ( ) :69 38
39 11B (2) 1. sol CED /home3/staff/ka002689/prog19upload 11b 2. ( 3. 1 ( ) ( ) Q1. Q2. Q3. ( ) 39
r11.dvi
19 11 ( ) 2019.4.20 1 / 1.1 ( n n O(n 2 O(n 2 ) ( 1 d n 1 n logn O(nlogn n ( n logn C 1.2 ( ( merge 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge int *ivec_new(int size) { int *a = (int*)malloc((size+1)
More informationr08.dvi
19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev
More informationohp08.dvi
19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data
More informationr07.dvi
19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1
More informationohp07.dvi
19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5
More informationohp03.dvi
19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0
More informationr03.dvi
19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---
More information( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1
() 2006 2 27 1 10 23 () 30 () 27 [1] p.97252 7 2 2.1 2.1.1 1 LIFO(last in first out, ) (push) (pup) 1 1: 2.1.2 1 List 4-1(p.100) stack[] stack top 1 2 (push) (pop) 1 2 void stack push(double val) val stack
More information£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡
(2018) 2018 5 17 0 0 if switch if if ( ) if ( 0) if ( ) if ( 0) if ( ) (0) if ( 0) if ( ) (0) ( ) ; if else if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 (0) 2 if else
More informationO(N) ( ) log 2 N
2005 11 21 1 1.1 2 O(N) () log 2 N 1.2 2 1 List 3-1 List 3-3 List 3-4? 3 3.1 3.1.1 List 2-1(p.70) 1 1 10 1 3.1.2 List 3-1(p.70-71) 1 1 2 1 2 2 1: 1 3 3.1.3 1 List 3-1(p.70-71) 2 #include stdlib.h
More informationBW BW
Induced Sorting BW 11T2042B 2015 3 23 1 1 1.1................................ 1 1.2................................... 1 2 BW 1 2.1..................................... 2 2.2 BW.................................
More informationuntitled
C -1 - -2 - concept lecture keywords FILE, fopen, fclose, fscanf, fprintf, EOF, r w a, typedef gifts.dat Yt JZK-3 Jizake tsumeawase 45 BSP-15 Body soap set 3 BT-2 Bath towel set 25 TEA-2 Koutya
More informationLIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP : 1
2007 7 17 2 1 1.1 LIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP 2 2 5 5 5 1: 1 2 データの追加 データの取り出し 5 2 5 2 5 2: 1.2 [1] pp.199 217 2 (binary tree) 2 2.1 (three: ) ( ) 秋田高専 校長 準学士課程学生
More informationMicrosoft Word - C.....u.K...doc
C uwêííôöðöõ Ð C ÔÖÐÖÕ ÐÊÉÌÊ C ÔÖÐÖÕÊ C ÔÖÐÖÕÊ Ç Ê Æ ~ if eíè ~ for ÒÑÒ ÌÆÊÉÉÊ ~ switch ÉeÍÈ ~ while ÒÑÒ ÊÍÍÔÖÐÖÕÊ ~ 1 C ÔÖÐÖÕ ÐÊÉÌÊ uê~ ÏÒÏÑ Ð ÓÏÖ CUI Ô ÑÊ ÏÒÏÑ ÔÖÐÖÕÎ d ÈÍÉÇÊ ÆÒ Ö ÒÐÑÒ ÊÔÎÏÖÎ d ÉÇÍÊ
More information新・明解C言語 ポインタ完全攻略
2 1-1 1-1 /* 1-1 */ 1 int n = 100; int *p = &n; printf(" n %d\n", n); /* n int */ printf("*&n %d\n", *&n); /* *&n int */ printf(" p %p\n", p); /* p int * */ printf("&*p %p\n", &*p); /* &*p int * */ printf("sizeof(n)
More informationPowerPoint プレゼンテーション
プログラミング応用 第 15 回 知的情報システム学科張 暁華 プログラミング応用 1 授業のマナー ------ 人の話を聞くときの社会常識 1. 欠席者のかわりに登録を行わない 倫理に反することをやらない あなたの信を問われている蟻の穴から堤防が決壊 2. 私語しないこと : 質問 意見は手を挙げて大きな声ではっきりと意思表示 3. 授業以外のことをしない : 携帯をカバンにいれ イヤホンを使って音楽等を聞かない授業中ゲームを遊ばない
More informationfp.gby
1 1 2 2 3 2 4 5 6 7 8 9 10 11 Haskell 12 13 Haskell 14 15 ( ) 16 ) 30 17 static 18 (IORef) 19 20 OK NG 21 Haskell (+) :: Num a => a -> a -> a sort :: Ord a => [a] -> [a] delete :: Eq a => a -> [a] -> [a]
More information‚æ4›ñ
( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9
More informationtuat1.dvi
( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )
More informationA common.h include #include <stdio.h> #include <time.h> #define MAXN int A[MAXN], n; double start,end; void inputdata(
2 065762A 19 7 13 1 2 2.1 common.h include #include #include #define MAXN 1000000 int A[MAXN], n; double start,end; void inputdata(void) int i; // printf(" "); scanf("%d",&n); // printf("
More informationuntitled
II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}
More information卒 業 研 究 報 告.PDF
C 13 2 9 1 1-1. 1-2. 2 2-1. 2-2. 2-3. 2-4. 3 3-1. 3-2. 3-3. 3-4. 3-5. 3-5-1. 3-5-2. 3-6. 3-6-1. 3-6-2. 4 5 6 7-1 - 1 1 1-1. 1-2. ++ Lisp Pascal Java Purl HTML Windows - 2-2 2 2-1. 1972 D.M. (Dennis M Ritchie)
More information新版明解C言語 実践編
2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,
More information1.3 ( ) ( ) C
1 1.1 (Data Base) (Container) C++ Java 1.2 1 1.3 ( ) ( ) 1. 2. 3. C++ 2 2.1 2.2 2.3 2 C Fortran C++ Java 3 3.1 (Vector) 1. 2. ( ) 3.2 3 3.3 C++ C++ STL C++ (Template) vector vector< > ; int arrayint vector
More informationdouble float
2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................
More information( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>
2007 12 5 1 2 2.1 ( ) 1 1: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 #define H WIN 400 // 8 #define W WIN 300 // 9
More informationI. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (
2016 2016 07 28 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF : 11011 N N 0 N N 11 1001 N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) 1100100 (2) 1111011 (3) 1110010 (4) 1001011
More information新・明解C言語 実践編
第 1 章 見 21 1-1 見えないエラー 見 List 1-1 "max2x1.h" a, b max2 List 1-1 chap01/max2x1.h max2 "max2x1.h" #define max2(a, b) ((a) > (b)? (a) : (b)) max2 List 1-2 List 1-2 chap01/max2x1test.c max2 #include
More information#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta
1 1. 1 #include 2 #include 3 #include 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 static bool KeyDownON = false; // 8 static bool KeyLeftON
More information/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1
I117 II I117 PROGRAMMING PRACTICE II 2 MEMORY MANAGEMENT 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara yasu@jaist.ac.jp / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming
More information:30 12:00 I. I VI II. III. IV. a d V. VI
2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx
More information/* max-heap property */ void insert(int val, int heap[], int counter) { int i = counter + 1; while( (i!= 1) && (heap[i/2] < val) ) { heap[i] = heap[i/2]; i = i/2; heap[i] = val; def insert(val, heap, counter):
More information1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou
1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() 2 double *a[ ]; double 1 malloc() double 1 malloc() free() 3 #include #include
More informationmemo
数理情報工学演習第一 C ( 第 12 回 ) 2017/07/11 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : ファイルの入出力 コマンドライン引数 2 分探索 最長単調増加列 2 ファイル操作の手続き : ファイル操作 ファイルからのデータ読み込み ファイルへのデータ書き出し 基本的な手順 読みこむ / 書き出すファイルを開く (fopen)
More informationPowerPoint Presentation
二分探索木 今回の要点 二分探索木の構造 どのような条件を満たさねばならないか? 二分探索が効率よく出来るため 二分探索木の操作 探索の方法 挿入の方法 削除の方法 各操作の実装コード 二分探索木の性質 どのような形がもっと探索に適しているか? 二分探索木とは 木構造 枝分かれした構造を表現するのに適する 根から葉に向かってたどる = 探索 何らかの特徴を持って構成されていると探索しやすい 二分探索木
More informationI. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *
2015 2015 07 30 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) +
More informationmemo
数理情報工学演習第一 C ( 第 8 回 ) 206/06/3 DEPARTMENT OF MATHEMATICAL INFORMATICS 今日の内容 : プロトタイプ宣言 ヘッダーファイル, プログラムの分割 プライオリティキュー ヒープ 課題 : ヒープソート 2 プロトタイプ宣言 C 言語では, 関数や変数は使用する前 ( ソースの上のほう ) に定義されている必要がある. double sub(int
More informationDA100データアクイジションユニット通信インタフェースユーザーズマニュアル
Instruction Manual Disk No. RE01 6th Edition: November 1999 (YK) All Rights Reserved, Copyright 1996 Yokogawa Electric Corporation 801234567 9 ABCDEF 1 2 3 4 1 2 3 4 1 2 3 4 1 2
More informationprogrammingII2019-v01
II 2019 2Q A 6/11 6/18 6/25 7/2 7/9 7/16 7/23 B 6/12 6/19 6/24 7/3 7/10 7/17 7/24 x = 0 dv(t) dt = g Z t2 t 1 dv(t) dt dt = Z t2 t 1 gdt g v(t 2 ) = v(t 1 ) + g(t 2 t 1 ) v v(t) x g(t 2 t 1 ) t 1 t 2
More information1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include
1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() malloc 2 #include #include #include enum LENGTH = 10 ; int
More informationCondition DAQ condition condition 2 3 XML key value
Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................
More information[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±
[1] #include printf("hello, world."); (G1) int -32768 32767 long int -2147483648 2147483647 float ±3.4 10 38 ±3.4 10 38 double ±1.7 10 308 ±1.7 10 308 char [2] #include int a, b, c, d,
More informationSystemC言語概論
SystemC CPU S/W 2004/01/29 4 SystemC 1 SystemC 2.0.1 CPU S/W 3 ISS SystemC Co-Simulation 2004/01/29 4 SystemC 2 ISS SystemC Co-Simulation GenericCPU_Base ( ) GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim
More information2008 DS T050049
DS T050049. PSP DS DS DS RPG DS OS Windows XP DevkiPro OS DS CPU ARM devkitarm MSYS MinGW MSYS MinGW Unix OS C++ C++ make nds nds DS DS micro SD Card nds DS DS DS nds C Java C++ nds nds DS 2008 DS T050049
More information(search: ) [1] ( ) 2 (linear search) (sequential search) 1
2005 11 14 1 1.1 2 1.2 (search:) [1] () 2 (linear search) (sequential search) 1 2.1 2.1.1 List 2-1(p.37) 1 1 13 n
More informationPowerPoint Presentation
p.130 p.198 p.208 2 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i i < NUM; i++ ) ) if if ( weight[i] > max ) max = weight[i]: if if ( weight[i] < min ) min = weight[i]: weight
More informationlexex.dvi
(2018, c ) http://istksckwanseiacjp/ ishiura/cpl/ 4 41 1 mini-c lexc,, 2 testlexc, lexc mini-c 1 ( ) mini-c ( ) (int, char, if, else, while, return 6 ) ( ) (+, -, *, /, %, &, =, ==,!=, >, >=,
More information# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n
II 6 / : 2001 11 21 (OCaml ) 1 (field) name id type # type student = {name : string; id : int};; type student = { name : string; id : int; } student {} type = { 1 : 1 ;...; n : n } { 1 = 1 ;...; n = n
More informationmemo
計数工学プログラミング演習 ( 第 6 回 ) 2016/05/24 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : 再帰呼び出し 2 分探索木 深さ優先探索 課題 : 2 分探索木を用いたソート 2 再帰呼び出し 関数が, 自分自身を呼び出すこと (recursive call, recursion) 再帰を使ってアルゴリズムを設計すると, 簡単になることが多い
More informationslide5.pptx
ソフトウェア工学入門 第 5 回コマンド作成 1 head コマンド作成 1 早速ですが 次のプログラムを head.c という名前で作成してください #include #include static void do_head(file *f, long nlines); int main(int argc, char *argv[]) { if (argc!=
More information第2回
明星大学情報学科 年後期 アルゴリズムとデータ構造 Ⅰ 第 回 Page 第 回基本データ構造 連結リストとその操作 -. リスト構造 データ部 と ポインタ部 で構成され ポインタをたどることによりデータを扱うことができる構造 -. 単方向リストとその操作 --. 単方向リスト 次のデータへのポインタを つだけ持っているデータ構造 ( データ部は 複数のデータを持っている場合もある ) データ部
More informationprogram.dvi
2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation
More informationII 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y
II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C 1 6 9 1 main main 1 NULL NULL 1 15 23 25 48 26 30 32 36 38 43 45 47 50 52 for 2 (a) 2 2 1 Yacc 2 (b) 2 3 yytext tmp2 ("") tmp2->next->word tmp2 yytext tmp2->next->word
More informationXMPによる並列化実装2
2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer
More informationプログラミング及び演習 第1回 講義概容・実行制御
プログラミング及び演習 第 12 回大規模プログラミング (2017/07/15) 講義担当大学院情報学研究科知能システム学専攻教授森健策大学院情報学研究科知能システム科学専攻助教小田昌宏 本日の講義 演習の内容 大きなプログラムを作る 教科書第 12 章 make の解説 プログラミングプロジェクト どんどんと進めてください 講義 演習ホームページ http://www.newves.org/~mori/17programming
More informationQuick Sort 計算機アルゴリズム特論 :2017 年度 只木進一
Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 2 基本的考え方 リスト ( あるいは配列 )SS の中の ある要素 xx(pivot) を選択 xx より小さい要素からなる部分リスト SS 1 xx より大きい要素からなる部分リスト SS 2 xx は SS 1 または SS 2 に含まれる 長さが 1 になるまで繰り返す pivot xx の選び方として 中央の要素を選択すると効率が良い
More informationj x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E
8 9 7 6 4 2 3 5 1 j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E a n 1 H = ae l j, j=1 l j = x j+1 x j, x n x 1 = n 1 j=1 l j, l j = ±l l > 0) n 1 H = ϵ l j, j=1 ϵ e x x
More information第5回お試しアカウント付き並列プログラミング講習会
qstat -l ID (qstat -f) qscript ID BATCH REQUEST: 253443.batch1 Name: test.sh Owner: uid=32637, gid=30123 Priority: 63 State: 1(RUNNING) Created at: Tue Jun 30 05:36:24 2009 Started at: Tue Jun 30 05:36:27
More informationアルゴリズムとデータ構造1
1 2005 7 22 22 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2005/index.html tech.ac.jp/k1sakai/lecture/alg/2005/index.html f(0) = 1, f(x) =
More informationmemo
数理情報工学演習第一 C プログラミング演習 ( 第 5 回 ) 2015/05/11 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : プロトタイプ宣言 ヘッダーファイル, プログラムの分割 課題 : 疎行列 2 プロトタイプ宣言 3 C 言語では, 関数や変数は使用する前 ( ソースの上のほう ) に定義されている必要がある. double sub(int
More informationcpp1.dvi
2017 c 1 C++ (1) C C++, C++, C 11, 12 13 (1) 14 (2) 11 1 n C++ //, [List 11] 1: #include // C 2: 3: int main(void) { 4: std::cout
More informationTaro-2分探索木Ⅱ(公開版).jtd
2 分探索木 Ⅱ 0. 目次 5. 2 分探索木の操作 5. 1 要素の探索 5. 2 直前の要素の探索 5. 3 直後の要素の探索 5. 4 要素の削除 5. 5 問題 問題 1-1 - 5. 2 分探索木の操作 5. 1 要素の探索 要素 44 の探索 (1) 要素 と 44 を比較して 左部分木をたどる (2) 要素 33 と 44 を比較して 右部分木をたどる (3) 要素 44 を見つけた
More information:30 12:00 I. I VI II. III. IV. a d V. VI
2017 2017 08 03 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF X [ S ] a S S ; X X X, S [, a, ], ; BNF X (parse tree) (1) [a;a] (2) [[a]] (3) [a;[a]] (4) [[a];a] : [a] X 2 222222
More informationex14.dvi
1,, 0, b (b b 2 b ) n k n = n j b j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, n j j j +1, 0,...,b 1 (digit). b b, n b 1 ñ, ñ = k (b 1 n j )b j b N, n b n, n = b N n, n =ñ+1 b N, n m n + m (mod b N ),
More informationMicrosoft PowerPoint - H22プログラミング第一(E)#12
平成 22 年 7 月 20 日 ( 火 ) 担当 : 秋山 泰 7 月 20 日 修正 プログラミング第一 (E) 第 12 回 メモリの動的割り当て - malloc( ), calloc( ), realloc( ) - free ( ), メモリリーク データ構造の動的割当て - 要素 1 つごとの動的割当て - 大きな単位でまとめた動的割当て 補足補足 main( ) の引数 : argc,
More informationK227 Java 2
1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html
More informationinst.c
1#include 2#include 3#include // 乱乱乱乱 PC 内ののの規規に従っっ 疑疑乱乱を発発ささの 4#include // 現現の時時を秒乱で返す乱乱 5 6#define DATA BIT0 // DATA P2.0 7#define CLOCK BIT1 // CLOCK P2.1
More informationex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double
More information2009 T
T060061 Wii Visual C++ 2008 Express Edition Visual C++ 2008 Express Edition ++ ++ Paint.net ++ 1 2009 T060061 2 1 4 2 4 2.1 Visual C++ 2008 Express Edition.......................... 4 2.2.....................................
More informationC B
C 095707B 2010 6 8 1 LEVE1 2 1.1 LEVEL 1.1................................................ 2 1.1.1 1................................................ 2 1.1.2 1.2..............................................
More information¥¢¥ë¥´¥ê¥º¥à¥¤¥ó¥È¥í¥À¥¯¥·¥ç¥ó ÎØ¹Ö #1
#1 id:motemen August 27, 2008 id:motemen 1-3 1-5 6-9 10-14 1 2 : n < a 1, a 2,..., a n > a 1 a 2 a n < a 1, a 2,..., a n > : Google: insertion sort site:youtube.com 1 : procedure Insertion-Sort(A) for
More information2008 ( 13 ) C LAPACK 2008 ( 13 )C LAPACK p. 1
2008 ( 13 ) C LAPACK LAPACK p. 1 Q & A Euler http://phase.hpcc.jp/phase/mppack/long.pdf KNOPPIX MT (Mersenne Twister) SFMT., ( ) ( ) ( ) ( ). LAPACK p. 2 C C, main Asir ( Asir ) ( ) (,,...), LAPACK p.
More informationDA13
データ構造とアルゴリズム第 13 回 知能情報学メジャー 和 俊和 5 整列 5.1 整列とは 5.2 単純な整列アルゴリズム 5.3 挿 ソートとその拡張 5.4 ヒープソート 5.5 クイックソート 5.6 マージソート 5.7 値の 較を いない整列 5.6 マージソート 1 与えられたデータ A を A " と A # にほぼ 等分する. 2A " と A # を整列する. このとき, データ数が
More informationWinHPC ppt
MPI.NET C# 2 2009 1 20 MPI.NET MPI.NET C# MPI.NET C# MPI MPI.NET 1 1 MPI.NET C# Hello World MPI.NET.NET Framework.NET C# API C# Microsoft.NET java.net (Visual Basic.NET Visual C++) C# class Helloworld
More informationPowerPoint プレゼンテーション
プログラミング応用演習 第 4 回再帰的構造体 前回の出席確認演習 #include int main() { FILE *fp; int c, linecount, length, maxlength; fp=fopen("/usr/share/dict/words","r"); if (fp == NULL) return 1; linecount=0; length=0;
More informationPowerPoint プレゼンテーション
プログラミング応用演習 第 4 回再帰的構造体 プログラミングを 余談 : 教えることの難しさ 丁寧に説明しないと分かってもらえない 説明すると 小難しくなる学生が目指すべきところプログラム例を説明されて理解できる違うやり方でも良いので自力で解決できる おっけー 動けば良い という意識でプログラミング 正しく動くことのチェックは必要 解答例と自分のやり方との比較が勉強になる 今日のお題 再帰的構造体
More informationPowerPoint Presentation
算法数理工学 第 2 回 定兼邦彦 クイックソート n 個の数に対して最悪実行時間 (n 2 ) のソーティングアルゴリズム 平均実行時間は (n log n) 記法に隠された定数も小さい in-place ( 一時的な配列が必要ない ) 2 クイックソートの記述 分割統治法に基づく 部分配列 A[p..r] のソーティング. 部分問題への分割 : 配列 A[p..r] を 2 つの部分配列 A[p..q]
More informationPowerPoint Presentation
整列アルゴリズムの基礎 この回の要点 整列とは? 整列処理の意味 整列の種類 整列の計算量 整列の安定性 単純な整列アルゴリズム バブルソート 選択ソート 挿入ソート それぞれのソートの特徴と実装 整列 (Sorting) とは 整列という操作 レコードの集まりを キーの値の大小関係に従って並べ替える操作 小さい 大きい = 昇順 (ascending order) 大きい 小さい = 降順 (descending
More informationmemo
計数工学プログラミング演習 ( 第 6 回 ) 2017/05/16 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : 再帰呼び出し 2 分探索木 深さ優先探索 課題 : 2 分探索木を用いたソート 2 再帰呼び出し 関数が, 自分自身を呼び出すこと (recursive call, recursion) 再帰を使ってアルゴリズムを設計すると, 簡単になることが多い
More informationbioinfo-a10s-4_align
4 (2) ATCAATCGATCGATC ATCCATTGAACCATC ATCAATCGATCGATC ATCAATCGAGGAGGATCGATC ATCAATCGATCGATC ATCAACGATC - CAAGACATTTTAC CATACACTTTAC CA-AGACATTTTAC CATACAC--TTTAC ** * ** ***** seq2 A A C G A seq1 C G A-CG
More informationとても使いやすい Boost の serialization
とても使いやすい Boost の serialization Zegrahm シリアライズ ( 直列化 ) シリアライズ ( 直列化 ) とは何か? オブジェクトデータをバイト列や XML フォーマットに変換すること もう少しわかりやすく表現すると オブジェクトの状態を表す変数 ( フィールド ) とオブジェクトの種類を表す何らかの識別子をファイル化出来るようなバイト列 XML フォーマット形式で書き出す事を言う
More informationTaro-リストⅢ(公開版).jtd
リスト Ⅲ 0. 目次 2. 基本的な操作 2. 1 リストから要素の削除 2. 2 リストの複写 2. 3 リストの連結 2. 4 問題 問題 1 問題 2-1 - 2. 基本的な操作 2. 1 リストから要素の削除 まず 一般的な処理を書き つぎに 特別な処理を書く 一般的な処理は 処理 1 : リスト中に 削除するデータを見つけ 削除する場合への対応 特別な処理は 処理 2 : 先頭のデータを削除する場合への対応
More informationMicrosoft PowerPoint - kougi10.ppt
C プログラミング演習 第 10 回二分探索木 1 例題 1. リストの併合 2 つのリストを併合するプログラムを動かしてみる head1 tail1 head2 tail2 NULL NULL head1 tail1 tail1 があると, リストの併合に便利 NULL 2 #include "stdafx.h" #include struct data_list { int data;
More informationQR
1 7 16 13 1 13.1 QR...................................... 2 13.1.1............................................ 2 13.1.2..................................... 3 13.1.3 QR........................................
More informationII ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D
II 8 2003 11 12 1 6 ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 Daisuke 8 =>. 73 Daisuke 35 Hiroshi 64 Ichiro 87 Junko
More information1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>
1 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout
More information£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡
(2018) 2018 5 24 ( ) while ( ) do while ( ); for ( ; ; ) while int i = 0; while (i < 100) { printf("i = %3d\n", i); i++; while int i = 0; i while (i < 100) { printf("i = %3d\n", i); i++; while int i =
More informationOriginal : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n
2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test
More information連載講座 : 高生産並列言語を使いこなす (4) ゲーム木探索の並列化 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 準備 問題の定義 αβ 法 16 2 αβ 法の並列化 概要 Young Brothers Wa
連載講座 : 高生産並列言語を使いこなす (4) ゲーム木探索の並列化 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 準備 16 1.1 問題の定義 16 1.2 αβ 法 16 2 αβ 法の並列化 17 2.1 概要 17 2.2 Young Brothers Wait Concept 17 2.3 段数による逐次化 18 2.4 適応的な待機 18 2. 強制終了
More informationdebug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology
I117 28 School of Information Science, Japan Advanced Institute of Science and Technology debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology 2008 1-2 1 a) b)
More informationfile:///D|/C言語の擬似クラス.txt
愛知障害者職業能力開発校 システム設計科 修了研究発表会報告書 題名 : C 言語の擬似クラス あらまし : C 言語でクラスを作れるという噂の真偽を確かめるために思考錯誤した まえがき : VC++ や Java その他オブジェクト指向の言語にはクラスが存在して クラスはオブジェクトの設計図である 手法 : C++ のクラスを解析して C++ のクラスを作成して C 言語に翻訳する class struct
More information8 if switch for while do while 2
(Basic Theory of Information Processing) ( ) if for while break continue 1 8 if switch for while do while 2 8.1 if (p.52) 8.1.1 if 1 if ( ) 2; 3 1 true 2 3 false 2 3 3 8.1.2 if-else (p.54) if ( ) 1; else
More information第2回
第 4 回基本データ構造 1 明星大学情報学科 2 3 年前期 アルゴリズムとデータ構造 Ⅰ 第 4 回 Page 1 配列 スタック キューとその操作 4-1. 配列とその操作 配列型 同じ型の変数を並べたもの 配列にする型は 基本型 配列型 構造体 ポインタいずれでもよい 要素の並べ方を 次元 という 1 次元配列 ( 直線状 ) 2 次元配列 ( 平面状 ) 3 次元配列 ( 立体状 ) a[5]
More information- - http://168iroha.net 018 10 14 i 1 1 1.1.................................................... 1 1.................................................... 7.1................................................
More informationI J
I 065763J 8 7 7 31 jikken/ +----- accumulation_demupa.c +----- accumulation_rain.c +----- frequency_demupa.c +----- frequency_rain.c +----- go.sh +----- graph_maker.sh +----- mesure-ryudai/ 2007/4/1 2007/6/30
More informationProg1_6th
2012 年 5 月 24 日 ( 木 ) 実施 多分岐のプログラム 前回は多段階の 2 分岐を組み合わせて 3 種類以上の場合分けを実現したが, 式の値の評価によって, 一度に多種類の場合分けを行う多分岐の利用によって見通しのよいプログラムを作成できる場合がある ( 流れ図は右図 ) 式の評価 : 値 1 : 値 2 : 値 n : 該当値無し 処理 1 処理 2 処理 n 既定の処理 switch
More informationSystemC 2.0を用いた簡易CPUバスモデルの設計
SystemC 2.0 CPU CPU CTD&SW CT-PF 2002/1/23 1 CPU BCA UTF GenericCPU IO (sc_main) 2002/1/23 2 CPU CPU CQ 1997 11 Page 207 4 Perl Verilog-HDL CPU / Verilog-HDL SystemC 2.0 (asm) ROM (test.hex) 2002/1/23
More informationdouble 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( "data.t
C++ 1 C C++ C++ C C C++ 1.1 C printf() scanf() C++ C 1-1 #include int a; scanf( "%d", &a ); printf( "a = %d\n", a ); C++ 1-2 int a; std::cin >> a; std::cout
More information1. 入力した正の整数を降順に並べ換えて出力するプログラムを作成せよ プログラムは個別にコンパイルし make コマンドで実行すること 入力データは 50 以下とし 以下の数が混在しているとする 16 進数 : 先頭 1 文字が x または X( エックスの小文字か大文字 ) 8 進数 : 先頭 1
1. 入力した正の整数を降順に並べ換えて出力するプログラムを作成せよ プログラムは個別にコンパイルし make コマンドで実行すること 入力データは 50 以下とし 以下の数が混在しているとする 16 進数 : 先頭 1 文字が x または X( エックスの小文字か大文字 ) 8 進数 : 先頭 1 文字が 0( 零 ) 10 進数 : 先頭 1 文字が 0( 零 ) 以外の数字 1.1 プログラム
More information1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l
C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................
More information