double float

Similar documents
第5回お試しアカウント付き並列プログラミング講習会

C

I J

‚æ4›ñ

[ 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言語 実践編

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

新版明解C言語 実践編

PowerPoint Presentation

橡Pro PDF

programmingII2019-v01

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

comment.dvi

memo

Condition DAQ condition condition 2 3 XML key value

プログラミング及び演習 第1回 講義概容・実行制御

r08.dvi

超初心者用

ohp08.dvi

lexex.dvi

main main Makefile Makefile C.5 Makefile Makefile Makefile A Mech (TA ) 1. Web ( iku

yacc.dvi

slide5.pptx

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

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

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

I 2 tutimura/ I 2 p.1/??

program.dvi

(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

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

untitled

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

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

2 P.S.P.T. P.S.P.T. wiki 26

P06.ppt

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

/* 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

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

untitled

t 2 2 t 2 t F ( ) p- 2 2 F 2 G F ( ) 2 2 F 2 G F ( ) 2 2 2

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

解きながら学ぶC++入門編


Smalltalk_

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

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

memo

P05.ppt

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

分割コンパイル (2018 年度 ) 担当 : 笹倉 佐藤 分割コンパイルとは 一つのプログラムのソースを複数のソースファイルに分けてコンパイルすること ある程度大きなプログラムの場合ソースファイルをいくつかに分割して開発するのが普通 1

プログラミング及び演習 第1回 講義概容・実行制御

Microsoft PowerPoint - kougi9.ppt

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

ex14.dvi

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

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

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

tuat1.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) * *

untitled

卒 業 研 究 報 告.PDF

K227 Java 2

G1. tateyama~$ gcc -c xxxxx.c ( ) xxxxx.o tateyama~$ gcc -o xxxxx.o yyyyy.o..... zzzzz.o Makefile make Makefile : xxxxx.o yyyyy.o... zzzzz.o ; gcc -o

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

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

r07.dvi

ohp07.dvi

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

p = 1, 2, cos 2n + p)πj = cos 2nπj 2n + p)πj, sin = sin 2nπj 7.1) f j = a ) 0 + a p + a n+p cos 2nπj p=1 p=0 1 + ) b n+p p=0 sin 2nπj 1 2 a 0 +

IP L09( Tue) : Time-stamp: Tue 14:52 JST hig TCP/IP. IP,,,. ( ) L09 IP (2017) 1 / 28

ex01.dvi

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

2 1. Ubuntu 1.1 OS OS OS ( OS ) OS ( OS ) VMware Player VMware Player jp/download/player/ URL VMware Plaeyr VMware

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

1.ppt

2008 ( 13 ) C LAPACK 2008 ( 13 )C LAPACK p. 1

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

第3章 OpenGL の基礎

解きながら学ぶJava入門編

第3章 OpenGL の基礎

r03.dvi

BW BW

6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = N t N 44.1 khz t = 1 sec j t f j {f 0, f 1, f 2,, f N 1

haskell.gby

スライド タイトルなし

Makefile, TCPソケットサーバ, コマンドライン引数

新コンフィギュレータのフレームワークについて

untitled

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

ohp03.dvi

joho07-1.ppt

ex01.dvi

SystemC言語概論

Microsoft Word - Training10_プリプロセッサ.docx

エラー処理・分割コンパイル・コマンドライン引数

O(N) ( ) log 2 N

1. 入力した正の整数を降順に並べ換えて出力するプログラムを作成せよ プログラムは個別にコンパイルし make コマンドで実行すること 入力データは 50 以下とし 以下の数が混在しているとする 16 進数 : 先頭 1 文字が x または X( エックスの小文字か大文字 ) 8 進数 : 先頭 1

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

Microsoft PowerPoint - CproNt02.ppt [互換モード]

Transcription:

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....................... 6 3.4............................ 6 4 7 5 7 5.1................................. 9 5.2............................... 9 6 9 6.1 Makefile................................ 9 6.2............................. 12 6.3................................. 14 7 15

1 1 1) Makefile make Makefile 2) main 1 3) 4) main a) b) c) main d) main 1 enum { False, True } ; 2 void Usage ( ) { 3 puts ( Usage :....... ) 4 } 5 6 int main ( ) 7 { 8 int s f l a g=f a l s e ; 9 i f ( ) { 10 Usage ( ) ; 11 e x i t ( 1 ) ; 12 } 13 i f ( s? ) { 14 s f l a g=true ; / s / 15 } 16 17 / / 18 } 5) 6) Segmentation Fault 7) C++ ( 2

2 C++ ) 8) gcc Wall O2 Wall O2 2 2.1 [ ] C,, 2.2 1 1 #include <s t d i o. h> 2 int z =1; 3 4 void func ( int x ) 5 { 6 s t a t i c int y=8; 7 extern int z ; 8 p r i n t f ( %d,%d,%d\n, ( x)++,y++,z++); 9 } 10 int main ( void ) 11 { 12 int x=2, y=5, z =4; 13 func (&y ) ; 14 p r i n t f ( %d,%d,%d\n, x++,y++,z++); 15 func (&z ) ; 16 p r i n t f ( %d,%d,%d\n, x++,y++,z++); 17 return ( 0 ) ; 18 } 2 3

3 1 #include <s t d i o. h> 2 3 void func ( int n1, int np2 ) 4 { 5 n1= np2 ; 6 np2 =8; 7 np2=&n1 ; 8 } 9 10 int main ( void ) 11 { 12 int n1=0, n2 =5; 13 int np1, np2, tmp ; 14 15 np1=&n2 ; 16 n2++; 17 tmp=&n1 ; 18 ( tmp)++; 19 np2=tmp ; 20 ( tmp)++; 21 22 p r i n t f ( n1=%d, n2=%d, np1=%d, np2=%d\n, n1, n2, np1, np2 ) ; 23 24 func ( np1, np2 ) ; 25 p r i n t f ( np1=%d, np2=%d\n, np1, np2 ) ; 26 } 3 3.1 ( ) 1 #define MAX 10 const 1 const int MAX=10; #define const 4

3.2 double float 3 1) #define const 2 (#define const ) 1 #include <s t d i o. h> 2 #define MIN 2 3 int main ( void ) 4 { 5 p r i n t f ( %d,3/min ) ; 6 } 2) a #define 1 #include <s t d i o. h> 2 const int MAX=3; 3 int main ( void ) 4 { 5 int a [MAX], i ; 6 for ( i =0; i <MAX; i ++) a [ i ]=0; 7... 8 } 3.2 double float 1) double x=0.0 0.1 10 1.0 2) double float 3) 1 #include <s t d i o. h> 2 3 int main ( void ) 4 { 5 double x =0.0; 6 while ( 1 ) { 7 x+=0.1; 8 i f ( x==1.0) break ; 9 } 10 5

3.3 main 3 11 return ( 0 ) ; 12 } 4) x=1.0 0.1 10.0 x double float time ($ time <command name>) ) double float float float 3.3 main 1) showarg 1 $. / showarg a b c 2 4 3. / showarg a b c 2) 2 ($./sum 1 2 3 ) 2 1 $. / sum 1 2 Usage : sum <num1> <num2> main double atof() 3.4 1) n calloc int a[n] i < n a[ i]=i a [] array a) b) 6

5 2) n int a[n ][ n] a array2 4 1) mylib.c a) fropen Failed to open ( ) 1 FILE fropen ( char fname ) b) fwopen Failed to open 1 FILE fwopen ( char fname ) 2) mylib.c ( ) mylib.h 3) make clean.o Makefile 5 1) 0 1 genrand 100 (UNIX ) 2) getdist b) h (Usage) 1 $. / g e t d i s t h 2 Usage : g e t d i s t [ o p t ion ] < f i l e > 7

5 3 option : 4 h ) Show t h i s message 5 n ) with l i n e number 6... ( )... c) a d) g (, * ) 0.1 1 0 0.1: 2 0. 1 0. 2 : 3 0. 2 0. 3 : 4... #define e) n f) C gcc getopt getopt g) Usage h) mylib.c i) make getdist getdist Makefile 3) getdist.c FILE( ) result.dat FILE #ifdef 4) gcc, DFILE #define FILE make fgetdist getdist.c, fgetdist make getdist getdist Makefile 8

5.1 6 5.1 1) fropen ( ) frpopen, mylib.c, mylib.h 2) getdist getdist2 1 $ genrand 100 g e t d i s t 2 2 $ genrand 100 g e t d i s t 2 g 3 $ g e t d i s t 2 < f i l e name> 4 $ g e t d i s t 2 g < f i l e name> 5.2 1) ẋ = x a) b) (x(t)) e 2) ( d x dt y ) = ( 0 1 1 0 ) ( x y a) b) ((x(t), y(t)) ) 6 6.1 Makefile Makefile 9

6.1 Makefile 6 1 arg : arg. c # arg arg. c 2 gcc o arg arg. c # 3 4 mycat : mycat. c # mycat mycat. c 5 gcc o mycat mycat. c # Makefile # Makefile arg 1 $ make arg arg arg arg.c Makefile Makefile $ 1 GCC = gcc 2 CFLAGS= Wall O2 3 L o a d l i b s= lm # 4 5 main : main. o mycat. o # main main. o mycat. o 6 ${GCC} ${CFLAGS} o $@ main. o mycat. o ${ L o a d l i b s } 7 8 arg : arg. o # arg arg. o 9 ${GCC} ${CFLAGS} o $@ $@. o ${ L o a d l i b s } 10 11 main. o : mycat. h main. c 12 ${GCC} ${CFLAGS} c o $@ main. c 13 14 mycat. o : mycat. c 15 ${GCC} ${CFLAGS} c o $@ mycat. c 16 17 c l e a n : 18 rm f. o 3 GCC, CFLAGS, Loadlibs ${GCC}, ${CFLAGS}, ${Loadlibs} 6 $@ 5 : ( main) 10

6.1 Makefile 6 make main Makefile main main.o mycat.o main.o main.o mycat.h, main.c main.o mycat.h main.c main.o main.o (.o) 1 $ make c l e a n Makefile Makefile 1 GCC = gcc 2 CFLAGS= Wall 3 L o a d l i b s= 4 5 main : main. o mycat. o 6 ${GCC} ${CFLAGS} o $@ main. o mycat. o ${ L o a d l i b s } 7 8 arg : arg. o 9 ${GCC} ${CFLAGS} o $@ $@. o ${ L o a d l i b s } 10 11 main. o : mycat. h main. c 12 13. c. o : 14 ${GCC} ${CFLAGS} c o $@ $< 15 16 c l e a n : 17 rm f. o.c.o.c.o mycat.o mycat.c.c.o 1 mycat. o : mycat. c 2 ${GCC} ${CFLAGS} c o $@ $< $@ : mycat.o $< : mycat.c mycat.o main.o mycat.h main.c 11

6.2 6.c.o 6.2 C 6.2.1 1 #define #define 1 #define MAX 100 MAX 100 1 #define MAX 10 2 int main ( void ) 3 { 4 int i ; 5 char buf [MAX] ; 6 for ( i =0; i <MAX; i ++) buf [ i ]=0; 7 } 6.2.2 1) x 1 #define s q r ( x ) ( ( x ) ( x ) ) () 2) 2 1 #define maxof ( x, y ) ( ( x>y )? x : y ) 3) 1 #define loop ( n ) for ( i =0; i <n;++ i ) 12

6.2 6 int i ; C++ OK 1 #define loop ( n ) for ( int i =0; i <n;++ i ) 4) 1 #define loop ( i, n ) for ( i =0; i <n;++ i ) 6.2.3 1 #i f d e f 2... 3 #e l i f 4... 5 #endif #ifdef DEBUG 1 #define DEBUG 2 int main ( void ) 3 { 4 #i f d e f DEBUG 5 p r i n t f ( ) ; 6 #endif 7 } #ifndef 1 #ifndef 2... // 3 #endif 1 #i f == 1 2... 3 #e l i f == 2 13

6.3 6 4... 5 #else 6... 7 #endif 6.3 UNIX ( data.txt) less 1 $ l e s s data. t x t main ( UNIX ) 1 $ cat data. t x t l e s s cat data.txt less cat less less data.txt 1.... 2 int main ( int argc, char argv ) 3 { 4 char f i l e n a m e ; 5 FILE fp ; 6 7 f i l e n a m e=argv [ argc 1]; / / 8 9 i f ( f i l e n a m e [0]== argc==1 ) { / 1 f i l e n a m e 10 1 ( ) / 11 fp = s t d i n ; 12 } else { / / 13 fp = fopen ( filename, r ) ; 14 i f ( fp == NULL ) { 15 f p r i n t f ( s t d e r r, %s. \ n, f i l e n a m e ) ; 16 e x i t ( 1 ) ; / / 14

7 17 } 18 } 19.... 20 } 7 1) nishii@sci.yamaguchi-u.ac.jp 2) 3) 15