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

Similar documents
(1 ) scanf(

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

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

PowerPoint Presentation

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

P05.ppt

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

P02.ppt

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

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

ex14.dvi

1 4 2 EP) (EP) (EP)

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

tuat1.dvi

ohp03.dvi

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

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

Taro-ファイル処理(公開版).jtd

Java

r08.dvi

新・明解C言語で学ぶアルゴリズムとデータ構造

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

本サンプル問題の著作権は日本商工会議所に帰属します また 本サンプル問題の無断転載 無断営利利用を厳禁します 本サンプル問題の内容や解答等に関するお問 い合わせは 受け付けておりませんので ご了承ください 日商プログラミング検定 STANDARD(C 言語 ) サンプル問題 知識科目 第 1 問 (

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

joho07-1.ppt

Microsoft PowerPoint - 説明2_演算と型(C_guide2)【2015新教材対応確認済み】.pptx

r03.dvi

橡Pro PDF

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

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

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

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

Microsoft Word - no15.docx

超初心者用

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

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

(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO

A common.h include #include <stdio.h> #include <time.h> #define MAXN int A[MAXN], n; double start,end; void inputdata(

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

untitled

prog-text.dvi

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

Microsoft PowerPoint - kougi4.ppt

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

新版明解C言語入門編

untitled

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

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

P03.ppt


情報処理演習 B8クラス

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

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

char int float double の変数型はそれぞれ 文字あるいは小さな整数 整数 実数 より精度の高い ( 数値のより大きい より小さい ) 実数 を扱う時に用いる 備考 : 基本型の説明に示した 浮動小数点 とは数値を指数表現で表す方法である 例えば は指数表現で 3 書く

ohp07.dvi

Transcription:

I 8 10 10 I ( 6 ) 10 10 1 / 23

1 C ( ) getchar(), gets(), scanf() ( ) putchar(), puts(), printf() 1 getchar(), putchar() 1 I ( 6 ) 10 10 2 / 23

1 (getchar 1 1) 1 #include<stdioh> 2 void main(void){ 3 int ch; // char ch; 4 ch = getchar(); 5 putchar(ch); 6 putchar( Y=n ); 7 } 1 a a putchar(ch); I ( 6 ) 10 10 3 / 23

1 (getchar 1 1) 1 #include<stdioh> 2 void main(void){ 3 int ch; // char ch; 4 ch = getchar(); 5 putchar(ch); 6 putchar( Y=n ); 7 } 2 abc a putchar(ch); I ( 6 ) 10 10 4 / 23

1 (getchar 1 2) 1 #include<stdioh> 2 void main(void){ 3 int ch; 4 ch = getchar(); 5 putchar(ch); 6 putchar(ch); 7 } a aa 5 6 putchar 1 gets(), puts() I ( 6 ) 10 10 5 / 23

(1 ) char ch[100]; 1 (char ) 100 1 1 1 1 ch[] ch[0] ch[1] ch[2] ch[99] 0 99 I ( 6 ) 10 10 6 / 23

(1 ) 1 char ch[100]="abc"; ch[] a b c 0? ch[0] ch[1] ch[2] ch[3] ch[4] ( ) 0 (ch[3] 0 ) 0 I ( 6 ) 10 10 7 / 23

(1 ) ( ) 1 #include<stdioh> 2 void main(void){ 3 char ch[100]="abcdefg"; 4 5 printf("%sy=n",ch); 6 ch[3]=0; 7 printf("%sy=n",ch); 8 ch[3]= D ; 9 printf("%sy=n",ch); 10 } abcdefg abc abcdefg I ( 6 ) 10 10 8 / 23

(1 ) 0 Y=0! ( ) 3 3 char ch[100]; 4 ch[100]="abcdefg"; I ( 6 ) 10 10 9 / 23

(1 ) (gets 1 1) 1 #include<stdioh> 2 int main(void){ 3 char ch[100]; 4 gets(ch); 5 puts(ch); 6 puts(ch); 7 return 0; 8 } abc abc abc (4 ) 5 puts 6 puts ( ) puts I ( 6 ) 10 10 10 / 23

(1 ) %c %s 3 char ch[100]="abcdefg"; 4 printf("%c Y=n",c); // 5 printf("%s Y=n",c); // 6 printf("%c Y=n",c[1]); // 7 printf("%s Y=n",c[1]); // %c 1 %s 7 I ( 6 ) 10 10 11 / 23

(1 ) (gets 1 2) 1 #include<stdioh> 2 int main(void){ 3 char ch[100]; 4 gets(ch); 5 printf("%sy=n",ch); 6 printf("%cy=n",ch[2]); 7 return 0; 8 } abc abc c 5 printf(); 6 printf(); I ( 6 ) 10 10 12 / 23

scanf() (scanf ) 1 #include<stdioh> 2 void main(void){ 3 int n; 4 double d; 5 scanf("%d",&n); // n & 6 printf("%dy=n",n); 7 scanf("%lf",&d); //double %lf 8 printf("%fy=n",d); 9 } 32 (5 ) 32 32123 (7 ) 32123000 I ( 6 ) 10 10 13 / 23

scanf() scanf() 1 #include<stdioh> 2 void main(void){ 3 char ch[100]; 4 scanf("%s",ch); // & 5 printf("%sy=n",ch); 6 } abc abc (4 ) 5 printf(); I ( 6 ) 10 10 14 / 23

scanf()! scanf() printf() scanf("n %d",&n); printf("n "); scanf("%d",&n); scanf() ( fgets, sscanf) I ( 6 ) 10 10 15 / 23

scanf() scanf() 2 I ( 6 ) 10 10 16 / 23

scanf() ( ) 1 #include <stdioh> 2 void main(void){ 3 int a, b; 4 char ch; 5 printf(" a="); 6 scanf("%d",&a); 7 printf(" ="); 8 scanf("%c",&ch); 9 printf(" b="); 10 scanf("%d",&b); 11 } a=12345 = b=67890 I ( 6 ) 10 10 17 / 23

scanf() 5, 6, 7, 8 6 scanf() (Y=n) ch %c 1 8 scanf(" %c",&ch); 8 scanf("%*c%c",&ch); I ( 6 ) 10 10 18 / 23

stdlibh rand() rand() I ( 6 ) 10 10 19 / 23

(1) a 1 #include <stdioh> 2 #include<stdlibh> 3 int main(void){ 4 int a; 5 a=rand(); 6 return 0; 7 } (2) 0 1 4 double b; 5 b=rand()/(rand_max+10); (3) 1 6 4 int a; 5 a=(int)(rand()/(rand_max+10)*6)+1; I ( 6 ) 10 10 20 / 23

rand() srand() rand() srand() seed rand() seed I ( 6 ) 10 10 21 / 23

( seed ) #include <stdioh> #include <timeh> #include <stdlibh> #include <windowsh> //Sleep int main(void){ srand(10); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); srand(10); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); srand((unsigned)time(null)); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); Sleep(1000); // 1000 srand((unsigned)time(null)); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); return 0; } I ( 6 ) 10 10 22 / 23

8444,10368,10345,30957 8444,10368,10345,30957 3657,19254,31547,15483 14223,9362,9631,15268 I ( 6 ) 10 10 23 / 23