橡Pro PDF

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

tuat1.dvi

ohp03.dvi

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

r03.dvi

Minimum C Minimum C Minimum C BNF T okenseq W hite Any 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

r07.dvi

ohp07.dvi

double float

PowerPoint Presentation

lexex.dvi

untitled

untitled

ex14.dvi

新・明解C言語 実践編

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

r08.dvi

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

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

新版明解C言語 実践編

C

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

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

program.dvi

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

(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

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

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

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

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

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

超初心者用

ex01.dvi

main

1.ppt

untitled

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

yacc.dvi

ex01.dvi

joho07-1.ppt

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

untitled

1 4 2 EP) (EP) (EP)

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

P06.ppt

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

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

PowerPoint プレゼンテーション

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();

comment.dvi

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

kiso2-06.key

P05.ppt

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

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

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル

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

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

I117 II I117 PROGRAMMING PRACTICE II SOFTWARE DEVELOPMENT ENV. 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara

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

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

memo

Transcription:

1

void main( ) char c; /* int c; */ int sum=0; while ((c = getchar())!= EOF) if(isdigit(c) ) sum += (c-'0'); printf("%d\n", sum); main()int i,sum=0; for(i=0;i<100;++i)sum+=i;printf("%d\n",sum); main( ) int i,sum=0; for (i=0; i<100; ++i) sum+=i; printf("%d\n",sum); main( ) int i, sum = 0; for (i = 0; i < 100; ++i) sum += i; printf("%d\n", sum); 2

void bar(void) int i, j; for (i=0; i<1000; ++i) for (j=0;j<10000; ++j); void foo(void) int i, j; for (i=0 ; i<1000; ++i) for (j=0 ; j<1000; ++j); main ( ) bar( ); foo( ); 3

#include <stdio.h> main() #include <stdio.h> char str[10], *p=str; gets(p); printf("%s\n", p); main() char *p; gets(p); printf("%s\n", p); 4

#define MAX_STACK 256 void push(double val); double pop(void); double surface_sp(void); #include <stdio.h> #include stack.h double stack[max_stack]; int sp=max_stack; double pop(void) * sp 5 + void push ( int ) 3 5

double surface_sp() CC = gcc CFLAGS = -O.c.o : $(CC) $(CFLAGS) -c $< TAR = stack OBJ = stack.o SRC = stack.c #define DEBUG main(void) HDR = stack.h $(TAR) : $(OBJ) $(HDR) int i; $(CC) $(CFLAGS) $(OBJ) -o $(TAR) -lm double x; #ifdef DEBUG x = pop( ); $(TAR):$(OBJ) $(HDR) for (i=0; i<257 ; ++i ) push( i ); #endif push ( 3 ); printf( %f\n, surface_sp( ) ); x = pop ( ); printf( %f\n, x); printf( %d\n, sp ); 6

7

int lex(char *buf) char tmp[max_stack]; int c; double value; main(void) char *buf; int c; while ( (c = getchar()) == ' t' c == ' ') ; if( c == '.' isdigit(c) ) else if ( isop(c) ) buf = (char *)calloc(sizeof(char),max_stack); while( (c = lex(buf))!= NULL ) if ( c == NUMBER ) printf("number %s n", buf); if ( c == OP ) printf("operator %s n", buf); else if ( c == ' n') return(null); else perror("unresolved character"); exit(1); int isop(char op) 8

#include <stdio.h> #include <stdlib.h> #include <string.h> #include "stack.h" char *rev_pol(void) char *buf, *out; static char tmp[max_stack]; int c; if ( ( buf = (char *)calloc(sizeof(char),max_stack) ) == NULL ) perror("memory is not available"); exit(1); if ( ( out = (char *)calloc(sizeof(char),,max_stack) ) == NULL ) perror("memory is not available"); exit(1); while( (c = lex(buf))!= NULL ) if ( c == NUMBER ) if ( c == OP ) while( sp!= MAX_STACK ) strcat(out," 0"); strcpy(tmp,out); free(buf); free(out); return(tmp); 9

int level(char c) int priority; return( priority ); lex.c stack.c rpol.c #ifdef DEBUG main(void) char *pol; int c; pol=(char *)malloc(max_stack); for(;;) pol=rev_pol(); printf( %s\n, pol); if ( (c=getchar()) == EOF) break; else ungetc(c,stdin); #endif pop() push() surface_sp() rev_pol() main() token isop() lex() level.c level() 10

char *token; char *get_token(char *eq) static char *buf=null, *begin_buf, *end_buf; if (buf == NULL) begin_buf= buf = (char *)malloc(strlen(eq)+1); strcpy(buf, eq); end_buf = buf + strlen(buf); if (buf < end_buf) if (*token == NULL) free(begin_buf); token = buf = NULL; else free(begin_buf); token = buf = NULL; return (token); 11

#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "stack.h" extern char *token; main(void) char *eq="2 3 + 5 *"; double tmp; extern char *token; double polish(char *eq) double tmp; while( get_token(eq)!= NULL ) if(isdigit(*token)) else if(*token == '+') else if(*token == '-') else if(*token == '*') else if(*token == '/') else if(*token == '^') else if(*token == '%') while( get_token(eq)!= NULL ) if(isdigit(*token)) printf("%f n", atof(token)); else printf("%c n", *token); else perror("undefined operation"); exit(1); if(query_sp()!= MAX_STACK-1) printf("sp=%d n", query_sp()); perror("bad expression"); exit(1); return pop(); 12

main(void) char *pol=null; int c; double x; pol = (char *)malloc(max_stack); pop() for(;;) pol=rev_pol(); push() x = polish(pol); surface_sp() printf("%g\n", x); if ( (c = getchar()) == EOF) break; else ungetc(c,stdin); free(pol); pol.c polish() token.c get_token() main() token stack.c rpol.c rev_pol() token lex.c isop() lex() level.c level() 13

14