II ( ) 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

Similar documents
I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

10

Bar-Code_GUIDE

バーコードプリントガイド

¥ƥ­¥¹¥ȥ¨¥ǥ£¥¿¤λȤ¤˽

基礎情報処理 I (文字型)

PPS40511.PDF

joho07-1.ppt

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

超初心者用

データロジックスキャニング株式会社

untitled

新・明解C言語 ポインタ完全攻略

H02_ROM_ indd

PR300 電力モニタ 通信インタフェース (RS-485通信,Ethernet通信)

H02_ROM_ indd

DS-3300 プログラミングマニュアル 設定項目 ページ 初期値設定マップ 1-2 ファームウェアバージョン情報 2 システム設定 3 読取機能設定 4 インターフェース設定 5 バーコード規格別読取設定 6-7 チェックデジット設定 8 読取桁数設定 9 キャラクタ付加設定 10 数字バーコード

printf("5つの整数を入力して下さい \n"); /* データ入力 */ for( /*** 02 ***/ ){ printf("%dつ目の入力 :",i+1); scanf("%d", /*** 03 ***/ ); sum=dat[0]; /* 合計値の初期設定 */ n_max= 0

4 Mule(Emacs)

MS240 JISⅡ半角カナ文字データを含むカード読み取り設定例

r07.dvi

ohp07.dvi

文字コードとその実装

r08.dvi

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

A-GAGE High - Resolution MINI ARRAY Instruction Manual Printed in Japan J20005M

ohp08.dvi

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) + x * x + x x (4) * *

tuat1.dvi

ohp03.dvi

1-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 >>

ex12.dvi

Microsoft Word - C.....u.K...doc

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

untitled

‚æ4›ñ

I. 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)* (

Taro-リストⅠ(公開版).jtd

Microsoft Word - 5J0080_EAN-128MenuBook_v023.doc

Microsoft Word - Cプログラミング演習(12)

第一章 系统讯息

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

‚æ2›ñ C„¾„ê‡Ìš|

PowerPoint Presentation

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

C言語によるアルゴリズムとデータ構造

r03.dvi

型番 USB :F830-U RS232C:F830-R 組込み式 2 次元コードリーダー F830 詳細設定マニュアル Ver1.0 1

プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; } Point; 問題 18. 問題 17 の

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

BW BW

:30 12:00 I. I VI II. III. IV. a d V. VI

file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose

PowerPoint プレゼンテーション

untitled

Taro-リストⅢ(公開版).jtd

ex14.dvi

卒 業 研 究 報 告.PDF

johokiso-char.pdf.pdf

double 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

データフォーマットの設定例 Ver.F

:30 12:00 I. I VI II. III. IV. a d V. VI

lexex.dvi

QuickScan L Bar Code Scanner スキャナ設定ガイド

C言語入門

WinHPC ppt

Prog1_15th

P05.ppt

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

C B

pptx

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

新版明解C言語 実践編

解きながら学ぶC言語

I J

新・明解C言語 実践編

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

1.ppt

XMPによる並列化実装2

< F2D837C E95CF CF68A4A94C5816A2E6A>

double float

kiso2-09.key

file:///D|/C言語の擬似クラス.txt

( )!?

1 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

( ) 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>

(K&R 2.9) ~, &,, >>, << 2. (K&R 5.7) 3. (K&R 5.9) 4. (K&R 5.10) (argc argv atoi(), atof() ) 5. (K&R 7.5) (K&R 7.6) - FILE, stdin, stdout, std

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru

初歩のC言語ターミナル_2014_May.pages

02: 変数と標準入出力

データロジックスキャニング株式会社

橡Pro PDF

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

Taro-再帰関数Ⅱ(公開版).jtd

Taro-プログラミングの基礎Ⅱ(公

slide5.pptx

Transcription:

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 23 Koji 89 Mari 67 Satoshi s1542h017% prog8-1.c C < <= 2 ( ) C 2 strcmp 1.1 C 1 strcmp int strcmp(const char *s1, const char *s2); strcpy strcmp #include <string.h> 1 2 ( ) s1 s2 strcmp 2 1 (1 ) int s1 s2 s1 s2 0 s1 s2 8 1

strcmp (char ) 2 2 1 ASCII strcmp strcmp("abc", "abc") == 0 strcmp("abc", "xyz") < 0 strcmp("ab", "abc") < 0 strcmp("abc", "abd") < 0 strcmp("a", "ABC") > 0 "a" "ABC" ASCII a A 2 1.2 B prog6-2.c quicksort ( ) ASCII prog8-1.c prog8-1.c #include <string.h> 1 quicksort ( ) 2 prog7-2.c ( ) 1-542 1-609 100 1 ( ±1% ) prg7-2.c 1 (1) ( 3 ) 1 (C ) 2 A. 1 ASCII strcasecmp ( ) strcmp strcasecmp 8 2

1 clock time (2) ±1% ( ) 10 ( ) (3) (2) (4) (1) (3) 3 1 ( ) (1) (1) (3) checktime checktime 3 checktime (1-1) num (int ) sec (double ) 2 (1-2) Record data Record dp (1-3) data num name ( ) ( "Test") (1-4) clock reset 0 (1-5) clock on (1-6) (1-6-4) clock time sec 4 (1-6-1) data num score ( ) (rand() ) (1-6-2) dp num data (1-6-3) quicksort dp num score (1-6-4) clock time (1-7) clock off (1-6) 8 3

(1-8) clock reset 0 (1-9) clock on (1-10) (1-6) 2 (1-10-1) data num score ( ) (rand() ) (1-10-2) clock time 3 (1-11) clock off (1-10) (1-12) (ExpResult ) checktime typedef struct { int repeat; /* */ double t1; /* ( ) */ double t2; /* ( ) */ } ExpResult; repeat (1-6) t1 (1-10) t2 (1-6) (2) num ( ) 3.0 checktime ExpResult r (3) num ( ) 10.0*r.t2/(r.t2-r.t1) 1 checktime r 4 (4) r.repeat r.t2 t1 ( ) 1 (r.t2-r.t1)/r.repeat 3 main Unix (Linux) Windows OS C ( ) main main 1 + 1 int main 2 (char * ) (char ** ) + 2 ( 0) ( ) 1 1 2 2... ( ) 0 3 (1-6-4) clock time 4 ±1% 10 8 4

args.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(int argc, char *argv[]) 5 { 6 int i; 7 8 printf("argc = %d\n", argc); 9 for (i = 0; i < argc; i++) 10 printf("argv[%d] = %s\n", i, argv[i]); 11 return EXIT_SUCCESS; 12 } args.c s1542h017% cc -o args args.c s1542h017%./args argc = 1 argv[0] =./args s1542h017%./args -hello argc = 2 argv[0] =./args argv[1] = -hello s1542h017%./args This is a test. argc = 5 argv[0] =./args argv[1] = This argv[2] = is argv[3] = a argv[4] = test. s1542h017% args.c 1 main ( ) 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 5 int main(int argc, char *argv[]) 6 { 7 int a, b; 8 9 if (argc < 4) { 10 printf(" \n"); 11 return EXIT_FAILURE; 12 } 13 if (sscanf(argv[1], "%d", &a)!= 1) { 14 printf(" 1 \n"); 15 return EXIT_FAILURE; 16 } 17 if (sscanf(argv[3], "%d", &b)!= 1) { 18 printf(" 3 \n"); 19 return EXIT_FAILURE; calc.c 8 5

20 } 21 22 if (strcmp(argv[2], " ") == 0) 23 printf("%d + %d = %d\n", a, b, a+b); 24 else if (strcmp(argv[2], " ") == 0) 25 printf("%d - %d = %d\n", a, b, a-b); 26 else if (strcmp(argv[2], " ") == 0) 27 printf("%d * %d = %d\n", a, b, a*b); 28 else if (strcmp(argv[2], " ") == 0) 29 printf("%d / %d = %d... %d\n", a, b, a/b, a%b); 30 else { 31 printf(" \n"); 32 return EXIT_FAILURE; 33 } 34 35 return EXIT_SUCCESS; 36 } s1542h017%./calc 23 5 23 + 5 = 28 s1542h017%./calc 23 5 23 * 5 = 115 s1542h017%./calc 23 5 23 / 5 = 4... 3 s1542h017%./calc 23 5 23-5 = 18 s1542h017%./calc 23 5 s1542h017% calc.c 4 2 mprog2 TA 4.1 prog8-1.c 1.2 quicksort 1. prog8-1.c 4.2 prog8-2.c prog7-2.c prog8-2.c prog8-2.c ( 100000 ) ( ) 1 ( ) 10 2. 8 6

±1% ( ) 10 prog8-2.c s1542h017%./prog8-2 s1542h017%./prog8-2 0 s1542h017%./prog8-2 10 10 (15.550-5.770) / 8356128 = 0.0000011704 s1542h017%./prog8-2 100 100 (11.910-1.810) / 601463 = 0.0000167924 s1542h017%./prog8-2 1000 1000 (11.240-1.280) / 47456 = 0.0002098786 s1542h017%./prog8-2 10000 10000 (11.370-1.400) / 2458 = 0.0040561432 s1542h017%./prog8-2 100000 100000 (11.530-1.570) / 119 = 0.0836974790 s1542h017%./prog8-2 1000000 s1542h017% 3. main prog7-3.c prog8-3.c prog8-2.c II 8 A. ASCII ( ) 0 127 1( ) ASCII ( ) ASCII ASCII ASCII 0 31 127 ( ) 8 7

0 NUL 16 DLE SP 0 @ P 32 48 64 80 96 112 p 1 SOH 17 DC1! 1 A Q a 33 49 65 81 97 113 q STX 2 18 DC2 " 2 B R b 34 50 66 82 98 114 r 3 ETX 19 DC3 # 3 C S c 35 51 67 83 99 115 s 4 EOT 20 DC4 $ 4 D T d 36 52 68 84 100 116 t 5 ENQ 21 NAK % 5 E U e 37 53 69 85 101 117 u 6 ACK 22 SYN & 6 F V f 38 54 70 86 102 118 v BEL 7 23 ETB 7 G W g 39 55 71 87 103 119 w BS 8 24 CAN ( 8 H X h 40 56 72 88 104 120 x HT EM ) 9 I Y i 9 25 41 57 73 89 105 121 y 1 ASCII LF 10 26 SUB * : J Z j 42 58 74 90 106 122 z VT 11 27 ESC + ; K [ k 43 59 75 91 107 123 { 12 13 14 15 FF CR SO SI 28 29 30 31 FS GS RS US 44 45 46 47, -. / 60 61 62 63 < = >? 76 77 78 79 L M N O 92 93 94 95 \ ] ^ _ 108 109 110 111 l m n o 124 125 126 127 } ~ DEL () 32 SP 5 (Space) 1 SP 33 126 ( ) ISO 646-US ISO 646-US ISO 646-JP JIS X 0201 Roman 92 126 2 ISO 646-US (ASCII ) ISO 646-JP (JIS X 0201 Roman) 2 ISO 646-JP (JIS X 0201 Roman) 92 ( ) 126 ( ) \ ( ) ~ ( ) C NUL Null C 6 7 \0 C BEL Bell \a BS Backspace \b ( )1 HT Horizontal Tabulation \t ( ) ( 8 ) LF Line feed 8 \n C 1 VT Vertical Tabulation \v ( ) FF Form Feed 9 \f CR Carriage Return \r 2 5 8 8

printf 1 byte ASCII 1 byte (= 8 bit) printf printf %c ( ) printf ascii.c 32 126 1 8 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int c; 7 8 for (c = 32; c <= 126; c++) { 9 printf("%3d=%c", c, c); 10 if (c%8 == 7 c == 126) 11 printf("\n"); 12 else 13 printf(" "); 14 } 15 16 return EXIT_SUCCESS; 17 } ascii.c 8 printf %3d %c c %3d c ( ) %c c 1 s1542h017% cc ascii.c -o ascii s1542h017%./ascii 32= 33=! 34=" 35=# 36=$ 37=% 38=& 39= 40=( 41=) 42=* 43=+ 44=, 45=- 46=. 47=/ 48=0 49=1 50=2 51=3 52=4 53=5 54=6 55=7 56=8 57=9 58=: 59=; 60=< 61== 62=> 63=? 64=@ 65=A 66=B 67=C 68=D 69=E 70=F 71=G 72=H 73=I 74=J 75=K 76=L 77=M 78=N 79=O 80=P 81=Q 82=R 83=S 84=T 85=U 86=V 87=W 88=X 89=Y 90=Z 91=[ 92=\ 93=] 94=^ 95=_ 96= 97=a 98=b 99=c 100=d 101=e 102=f 103=g 104=h 105=i 106=j 107=k 108=l 109=m 110=n 111=o 112=p 113=q 114=r 115=s 116=t 117=u 118=v 119=w 120=x 121=y 122=z 123={ 124= 125=} 126=~ s1542h017% ascii.c 2 8 10 4.2 3 SP ( ) 4 New Line 5 8 9

C ( ) (int ) C A A (ASCII 65) 8 8 2 C \n ( ) \ \ ( ) \\ ASCII ascii.c ascii2.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int c; 7 8 for (c = ; c <= ~ ; c++) 9 printf("%3d=%c%c", c, c, (c%8 == 7 c == ~ )? \n : ); 10 return EXIT_SUCCESS; 11 } char ASCII 0 127 C char char 1 byte (= 8 bit) 10 128 127 0 255 char 11 char int char char int C char char ch; 1 char 1 char ( ) int ascii.c ascii2.c 5 int c; char c; c ( ) char 10 C 11 C 127 127 8 10

printf 2 char char int int printf scanf 1 byte scanf 1 byte %c ( ) (scanf ) %c char (char ) chars.c 9 scanf char ( ) 5 char c; int c; 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 char c; 7 8 printf(" = "); 9 do { 10 scanf("%c", &c); 11 printf("%3d=%c\n", c, c); 12 } while (c!= \n ); 13 return EXIT_SUCCESS; 14 } chars.c s1542h017%./chars = This is a test. 84=T 104=h 105=i 115=s 32= 105=i 115=s 32= 97=a 32= 116=t 101=e 115=s 116=t 46=. 10= chars.c s1542h017% chars.c (Enter) 8 11

chars 7 printf = (Enter) 9 scanf This is a test. (Enter) T 16 scanf T c main scanf scanf %d %f %lf () ( ) %c 1 %c " %c" scanf ( ) B. prog7-1.c quicksort 1 int quicksort(record *d[], int h, int t) 2 { 3 Record *tmp; 4 int r; 5 int i, j, count = 0; 6 7 if (h >= t) 8 return count; 9 10 r = d[(h+t)/2]->score; 11 i = h; 12 j = t; 13 while (1) { 14 count++; 15 while (d[i]->score < r) { 16 i++; 17 count++; 18 } 19 count++; 20 while (r < d[j]->score) { 21 j--; 22 count++; 23 } 24 if (j <= i) 25 break; 26 tmp = d[i]; 27 d[i++] = d[j]; 28 d[j--] = tmp; 29 } 30 count += quicksort(d, h, i-1); 31 count += quicksort(d, j+1, t); 32 return count; 33 } 8 12