pptx

Similar documents
1.ppt

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

超初心者用

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

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

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

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

[ 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:

Informatics 2014

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

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

untitled

C

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

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

r07.dvi

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

ohp07.dvi

Taro-ポインタ変数Ⅰ(公開版).j

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

untitled

Informatics 2015

tuat1.dvi

C 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in

ohp03.dvi

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

P05.ppt

O(N) ( ) log 2 N

導入基礎演習.ppt

untitled

I void* School of Information Science, Japan Advanced Institute of Science and Technology

programmingII2019-v01

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

r03.dvi

WinHPC ppt

r08.dvi

10

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

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

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

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

卒 業 研 究 報 告.PDF

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

kiso2-06.key

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

新版明解C言語 実践編

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

c-all.dvi

橡Pro PDF

ohp08.dvi

第2回

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

kiso2-03.key

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

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

Informatics 2010.key

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

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

PowerPoint Presentation

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

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


joho07-1.ppt

‚æ4›ñ

1st-session key

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

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1

問 2 ( 型変換 ) 次のプログラムを実行しても正しい結果が得られない 何が間違いかを指摘し 正しく修正せよ ただし int サイズが 2 バイト long サイズが 4 バイトの処理系での演算を仮定する #include <stdio.h> int main( void ) { int a =


x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )

C , C++ C C++ C++ C cpprefjp - C++ 1 C CUI 2.1 donothing.cpp 1

K227 Java 2

1.1 1 C IIA $ cd comp3a %endminipage ~/comp3a mkdir $ mkdir comp3a $ cd comp3a C.c Emacs Cntrol x Control s 2 Emacs Control-x Control-f Control-

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


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

ex01.dvi

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

kiso2-09.key

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

P06.ppt

main

double float

Java updated

Java学習教材

2009 T

cpp1.dvi

BW BW

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裱£²²ó ¡Ý½ÉÂꣲ¤Î²òÀ⡤±é½¬£²¡Ý

(2 Linux Mozilla [ ] [ ] [ ] [ ] URL 2 qkc, nkc ~/.cshrc (emacs 2 set path=($path /usr/meiji/pub/linux/bin tcsh b

ex12.dvi

<4D F736F F D2091E63589F182628CBE8CEA8D758DC08E9197BF2E646F6378>

Microsoft Word - Sample_CQS-Report_English_backslant.doc

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

ex01.dvi

1 4 2 EP) (EP) (EP)

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

17 1. strucr Potter ( ) Harry Potter and the Philosopher s Stone 1997 English Title : Harry Potter and the Philosopher s Stone : : 1997 #include<stdio

Microsoft PowerPoint - C言語の復習(配布用).ppt [互換モード]

Transcription:

iphone 2010 8 18 C xkozima@myu.ac.jp

C Hello, World!

Hello World hello.c! printf( Hello, World!\n );! os> ls! hello.c! os> cc hello.c o hello! os> ls! hello!!hello.c! os>./hello! Hello, World!! os>! os> ls! hello.c! os> cc hello.c! os> ls! a.out!!hello.c! os>./a.out! Hello, World!! os>!

Hello World hello.c! printf( Hello, World!\n );! Xcode Create a new Xcode Project Mac OS X / Application Command Line Tool Run Console

Hello World hello.c! printf( Hello, World!\n );! Windows Visual C++ (Express Edition C++

Hello World hello.c! printf( Hello, World!\n );! C main Koz koz _ printf

int keisan.c! int x;! int y;! int wa, sa;! x = 17;! y = 6;! wa = x + y;! sa = x y;! printf( wa: %d\n, wa);! printf( sa: %d\n, sa);! = ; %d \n

int ans_i;! float ans_f;! ans_i = 17 / 6;! printf( ans_i: %d\n, ans_i);! ans_f = 17 / 6;! printf( ans_f: %f\n, ans_f);! ans_f = 17.0 / 6.0;! printf( ans_f: %f\n, ans_f);! ans_i = 17.0 / 6.0;! printf( ans_i: %d\n, ans_i);! ans_f = (float) 17 / 6;! printf( ans_f: %f\n, ans_f);! keisan.c! float double / ans_i: 2 / ans_f: 2.000000 / ans_f: 2.833333 ans_i: 2 (float) 17 17.0 %f

// 32bit: -2147483648 2147483647! int score;! int income, outgo;! score = 80;! income = 15000; outgo = 17800;! //! float height, weight;! double kousoku;! height = 1.70; weight = 62.0;! kousoku = 299792458.0;! // 299792458 m/s! kousoku = 0.299792458e9;! // 0.299 10 9! //! char c1, c2;! //! /* */!! c1 = A ;!!! //! c2 = 65;!!! // 0 255 ASCII!

if else for, while

if / if else branch1.c! int n = 12;! if (n > 10)! (n > 10) printf( n is greater than 10\n );! if (n == 0)! == printf( n is zero\n );! if (n < 10)! printf( n is less than 10\n );! if (n % 2 == 0)! n % 2 2 printf( n is even number\n );! else! printf( n is odd number\n );! return 0;!

if / if else branch2.c! float height_m = 1.70;! float weight_kg = 62.0;! float bmi = weight_kg / (height_m *height_m);! if (height_m > 2.5) printf( Use [m] for height.\n );! printf( Your BMI is %f\n, bmi);! if (bmi >= 25.0)! printf( WARNING!\n );! else! printf( SAFE\n );! return 0;! { } 25.0 25.0

if else if else if else float height_m = 1.70;! float weight_kg = 62.0;! float bmi = weight_kg / (height_m *height_m);! branch3.c! printf( Your BMI is %f\n, bmi);! if (bmi >= 30.0)! printf( You are obese!\n );! else if (bmi >= 25.0)! printf( You are overweight.\n );! else if (bmi >= 18.5)! printf( You are normal.\n );! else! printf( You are underweight.\n );! return 0;!

for int k, acc = 0;! int n = 10;! for (k = 1; k <= n; k = k + 1)! acc = acc + k;! printf( 1+...+%d = %d\n, n, acc);! return 0;! 1+...+10 = 55 loop1.c! k = k + 1 k++ acc = acc + k acc += k for ( ; ; ) ; for ( ; ; ) { ; ;} / { }

while loop2.c! int k, acc = 0;! int n = 10;! k = 1;! while (k <= n) acc += k;! k++;! 1+...+10 = 55 printf( 1+...+%d = %d\n, n, acc);! while ( ) ; / { } while ( ) { ; ;}

branch4.c! int n = 10;! while (n) n 0 printf( %d\n, n);! if (n > 0) n--;! else n++;! printf( BANG!\n );! return 0;! (n > 0) n > 0 1 n <= 0 0

int sum (int n)! int k, acc = 0;! kansu1.c! y = f(x) sum(n) n for (k = 1; k <= n; k++)! acc += k;! return acc;! acc int ans;! main 20 sum ans ans = sum(20);! printf( 1+...+20 = %d\n, ans);! main 0 OS

int sum (int n);! int ans;! ans = sum(20);! printf( 1+...+20 = %d\n, ans);! int sum (int n)! int k, acc = 0;! for (k = 1; k <= n; k++)! acc += k;! return acc;! kansu2.c! { } sum int ans;! int sum(int n);! ans = sum(20);! printf(...);! int sum(int);

void bmi_check (float bmi)! if (bmi >= 25.0)! printf( You are fat.\n );! else if (bmi >= 18.5)! printf( You are normal.\n );! else! printf( You are thin.\n );! return;! float height_m = 1.70;! float weight_kg = 62.0;! float bmi = weight_kg / (height_m *height_m);! printf( Your BMI is %f\n, bmi);! bmi_check(bmi);! kansu3.c! void return; (return; main int

int RandomValue = 14992;! int random (void)! int tmp = RandomValue * 673 + 944;! RandomValue = (tmp % 1000000) / 10;! return RandomValue;! int i;! for (i = 0; i < 10; i++) int ran;! ran = random();! printf( random() = %d\n, ran);! kansu4.c! 0 99999 ran {} random() = 9056! random() = 9563! random() = 43684! random() = 40027! random() = 93911! random() = 20304! random() = 66553! random() = 79111! random() = 24264! random() = 33061!

int x = 123;! int square (int x)! x = x * x;! return x;! printf( before: x = %d\n, x);! int x = 0;! while (x < 8) { } printf( while : x = %d\n, x);! if (x % 2 == 0) int x, y;! x = square(12); y = square(15);! printf( if : x = %d\n, x);! x++;! printf( after : x = %d\n, x);! (int x) kansu4.c! before: x = 123! while : x = 0! if : x = 144! while : x = 1! while : x = 2! if : x = 144! while : x = 3! while : x = 4! if : x = 144! while : x = 5! while : x = 6! if : x = 144! while : x = 7! after : x = 8

int a[8];! a array1.c! a[0] = 123; a[1] = 234; a[2] = 345; a[3] = 456;! a[4] = 567; a[5] = 678; a[6] = 789; a[7] = 890;! int i, acc = 0;! for (i = 0; i < 8; i++) printf( a[%d] = %d\n, i, a[i]);! acc += a[i];! printf( mean = %f, (float) acc / 8);! acc

float array_mean (int x[8])! int i, acc = 0;! for (i = 0; i < 8; i++)! acc += x[i];! return (float) acc / 8;! int a[8];! x a a[0] = 123; a[1] = 234; a[2] = 345; a[3] = 456;! a[4] = 567; a[5] = 678; a[6] = 789; a[7] = 890;! float mean! mean = array_mean(a);! printf( mean = %f\n, mean);! array2.c! x. (int x[])

void array_init (int x[8])! x[0] = 123; x[1] = 234; x[2] = 345; x[3] = 456;! x[4] = 567; x[5] = 678; x[6] = 789; x[7] = 890;! int a[8];! array_init(a);! int i, acc = 0;! for (i = 0; i < 8; i++) printf( a[%d] = %d\n, i, a[i]);! acc += a[i];! printf( mean = %f\n, (float) acc / 8);! x a array3.c! x. (int x[])

char c;! array4.c! This is the letter A.! This is a string MYU.! This is also a string MYU. 0 255 c = A ;! printf( This is the letter %c.\n, c);! char s[4];! %c s[0] = M ; s[1] = Y ;! s[2] = U ; s[3] = \0 ;! printf( This is a string %s.\n, s);! printf( This is also a string %s.\n, MYU );! s! \0!

char s[4] = MYU ;! int i;! s array5.c! s MYU!! for (i = 0; i < 4; i++) if (s[i] == \0 )! if (s[i] == 0)! printf( s[%d] = end\n, i);! else! printf( s[%d] = %c \n, i, s[i]);! s[0] = 'M! s[1] = 'Y! s[2] = 'U! s[3] = end

int k;! int *p;! p! p = &k;! &k k! k = 123;! printf( k = %d, *p = %d\n, k, *p);! k = 234;! printf( k = %d, *p = %d\n, k, *p);! *p = 345;! printf( k = %d, *p = %d\n, k, *p);! pointer1.c! k p? k p *p p!! k = 123, *p = 123! k = 234, *p = 234! k = 345, *p = 345

pointer2.c! char *s;! s? s = Miyagi ;! int i = 0;! while (s[i]!= \0 ) printf( s[%d] = %c \n, i, s[i]);! i++;! printf( s[%d] = end\n, i);! s s[0] = M! s[1] = i! s[2] = y! s[3] = a! s[4] = g! s[5] = i! s[6] = end

void explode (char *str)! int i = 0;! while (str[i]!= \0 ) printf( str[%d] = %c \n, i, str[i]);! i++;! printf( str[%d] = end\n, i);! char *s;! s = Miyagi ;! explode(s);! s pointer3.c! str[0] = M! str[1] = i! str[2] = y! str[3] = a! str[4] = g! str[5] = i! str[6] = end

void explode (char *str)! while (*str!= \0 ) printf( char = %c \n, *str);! str++;! printf( str[%d] = end\n, i);! char *s;! s = Miyagi ;! explode(s);! s pointer4.c! while (*str) printf( char = %c\n, *str);! str++;! }! char = M! char = i! char = y! char = a! char = g! char = i! char = end

struct

struct gp_data float latitude;!!// -90..90! float longitude;!!// -180..180! float altitude;!!// [m]! };! void gp_print (struct gp_data *gp)! printf( latitude : %f\n, gp->latitude);! printf( longitude: %f\n, gp->longitude);! printf( altitude : %f\n, gp->altitude);! struct gp_data gp_myu;! gp_myu.latitude = 38.348337;! gp_myu.longitude = 140.839502;! gp_myu.altitude = 92.50;! gp_print(&gp_myu);! *gp! struct1.c! x->y! x! y! x.y! x! y! &gp_myu! gp_myu!

#include <math.h>! struct pos double x, y;! };! double distance (struct pos *p1, struct pos *p2)! float dx = p1->x - p2->x,! dy = p1->y - p2->y;! return sqrt(dx*dx + dy*dy);! double sqrt(double);! struct pos now, goal;! now.x = 1.23; now.y = 2.34;! goal.x = 3.45; goal.y = 4.56;! double d = distance(&now, &goal);! printf( distance = %f\n, d);! struct2.c! sqrt, sin! now, goal!

// Tobii! // 120! struct _TobiiGazeData // int timestamp_sec; // int timestamp_microsec; // // float x_gazepos_lefteye; // float y_gazepos_lefteye; // float x_camerapos_lefteye; // Tobii float y_camerapos_lefteye; // Tobii float diameter_pupil_lefteye; // float distance_lefteye; // long validity_lefteye; // 0=,1-3=,4= // float x_gazepos_righteye; // float y_gazepos_righteye; // float x_camerapos_righteye; // Tobii float y_camerapos_righteye; // Tobii float diameter_pupil_righteye; // float distance_righteye; // int validity_righteye; // 0=,1-3=,4= };!

void ango (char *str)! int i = 0;! while (str[i]!= \0 ) str[i] += 1;! i++;! char *s = Miyagi ;! printf( moto: %s\n, s);! ango(s);! printf( ango: %s\n, s);! s memory1.c!!!!

void ango (char *str)! int i = 0;! while (str[i]!= \0 ) str[i] += 1;! i++;!! Miyagi! char s[] = Miyagi ;! printf( moto: %s\n, s);! ango(s);! printf( ango: %s\n, s);! s memory2.c!! moto: Miyagi! ango: Njzbhj

#include <stdlib.h>! char s_data[5] = data ;! char *s_code = code ;! char s_stack[6] = stack ;! char *s_heap;! s_heap = malloc(5);! s_heap[0] = h ; s_heap[1] = e ;! s_heap[2] = a ; s_heap[3] = p ;! s_heap[4] = \0 ;! printf( %s, %s, %s, %s\n,! s_code, s_data, s_stack, s_heap );! memory3.c!! code!!! data!!! heap! malloc!! stack!!! code, data, stack, heap

char *s_code = code ;! printf( %s\n, s_code);! s_code[0] = C ;! printf( %s\n, s_code);!!!!!!! memory4.c!! code!!! data!!! heap! malloc!! stack!!!

char s_data[5] = data ;! void dosomething (void)!! s_data[0] = D ;!! printf( %s\n, s_data);! dosomething();! printf( %s\n, s_data);! data! Data memory5.c!! code!!! data!!! heap! malloc!! stack!!!

void fun1 (void)! char s_stack[6] = STACK ;! printf( fun1: %s\n, s_stack);! char s_stack[6] = stack ;! printf( main: %s\n, s_stack);! fun1();! printf( main: %s\n, s_stack);! (main)! s_stack[6]! (fun1)! s_stack[6]! (main)! (main)!! s_stack[6]!! s_stack[6]! memory6.c!! code!!! data!!! heap! malloc!! stack!!! main: stack! fun1: STACK! main: stack

fun1: stack! fun2: Stack! void fun2 (char *str)! fun1: Stack str[0] = S ;! printf( fun2: %s\n, str);! void fun1 (void)! char s_stack[6] = stack ;! printf( fun1: %s\n, s_stack);! fun2(s_stack);! printf( fun1: %s\n, s_stack);! fun1();! (main)!! (fun1)! s_stack[6]! (main)!! (fun2)! str! (fun1)! s_stack[6]! (main)! memory7.c!! code!!! data!!! heap! malloc!! stack!!!! (fun1)! s_stack[6]! (main)!!

char *funok (char *str)! str[0] = S ;! return str;!! (main)! s_st[],res! char *funng ()! char str[6] = STACK ;! return str;!!! (funng)! str[6]! char s_st[6] = stack ;! char *res;! res = funok(s_st); printf( %s\n, res);! res = funng(); printf( %s\n, res);! memory8.c! (main)! (main)!! s_st[],res!! s_st[],res! Stack! *error*!

malloc #include <stdlib.h>! char *func (void)! char *s_heap;!! s_heap = (char *) malloc(5);! s_heap[0] = h ; s_heap[1] = e ;! s_heap[2] = a ; s_heap[3] = p ;! s_heap[4] = \0 ;! printf( func: %s\n, s_heap);! return s_heap;!!! char *res;!! res = func();! printf( main: %s\n, res);! memory9.c!! code!!! data!!! heap! malloc!! stack!!! func: heap! main: heap

malloc // ex.! char *s;!! s = (char *) malloc(3);! s[0] = O ; s[0] = K ; s[0] = \0 ;! // ex.! int *a;!! a = (int *) malloc(sizeof(int) * 4);! a[0] = 14; a[1] = 15; a[2] = 92; a[3] = 65;! //! struct pos *p;!! p = (struct pos *) malloc(sizeof(struct pos));! p->x = 12.3; p->y = 23.4;! //! free(s);! free(a);! free(p);! malloc!

//! char sd[5] = data ;! void fun (void)! char *sc = code ;! char ss[6] = stack ;! char *sh = (char *) malloc(5);! //!!!!!!!!malloc free!! code!!! data!!! heap! malloc!! stack!!! (fun2)! str! (fun1)! s_stack[6]! (fun1)! s_stack[6]! (fun1)! s_stack[6]! (main)!! (main)!! (main)!! (main)!!