1 1 2 2 2.1................................................ 2 2.2......................................... 2 3 Battle Ship 3 3.1......................



Similar documents
Java

: Java JavaSript

改訂版 :基本的な文字化の原則(Basic Transcription System for Japanese: BTSJ)

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

PowerPoint Presentation

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

Prog1_14th

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

10

‚æ4›ñ

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

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

プログラミング基礎

PowerPoint プレゼンテーション

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

main

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

fuga scanf("%lf%*c",&fuga); 改行文字を読み捨てる 10 進数の整数 おまじない取り込んだ値を代入する変数 scanf( %d%*c,&hoge); キーボードから取り込め という命令 1: scanf 1 1: int double scanf %d %lf printf

●70974_100_AC009160_KAPヘ<3099>ーシス自動車約款(11.10).indb

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

!!!!!

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

C ( ) C ( ) C C C C C 1 Fortran Character*72 name Integer age Real income 3 1 C mandata mandata ( ) name age income mandata ( ) mandat

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

untitled

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

P03.ppt

超初心者用

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

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

コーディング基準.PDF

K227 Java 2

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

新版明解C言語 実践編

8 if switch for while do while 2

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

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

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

Lecture on

REALV5_A4…p_Ł\1_4A_OCF

untitled

「都市から地方への人材誘致・移住促進に関する調査」

<91498EE88CA D815B2E786C73>

〔 大 会 役 員 〕

橡本体資料+参考条文.PDF

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

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

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

Microsoft PowerPoint - C_Programming(3).pptx

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

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

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

第3章 OpenGL の基礎

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

untitled

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

double float

2

<4D F736F F D20438CBE8CEA8D758DC F0939A82C282AB2E646F63>

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

Microsoft PowerPoint - lecture201509c_1.pptx

実装規約第1.1版R2.PDF

jikken.dvi


Java updated

-34-


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

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

P05.ppt

新・明解C言語 実践編

Java演習(4) -- 変数と型 --

卒 業 研 究 報 告.PDF

untitled

r08.dvi

広報さがみはら第1242号

Microsoft PowerPoint - 14Chap17.ppt

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

fp.gby

橡Taro9-生徒の活動.PDF


#"

10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) / 10

ohp08.dvi

血統詳細‐本番/3日目 482‐750

r07.dvi

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 )

P06.ppt

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

ohp07.dvi

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

ディジタル信号処理

講習No.12

橡Pro PDF

TEX American Mathematical Society PostScript Adobe Systems Incorporated

ex01.dvi

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

r03.dvi

Transcription:

2013 10H071

1 1 2 2 2.1................................................ 2 2.2......................................... 2 3 Battle Ship 3 3.1............................................ 3 3.2............................................ 3 3.3 Battle Ship...................................... 3 4 Compare 4 5 6 5.1.................................................. 6 5.2.................................................. 6 6 8 7 9 8 10 8.1........................................ 10 8.2.................................. 10 8.3............................... 10 A 12 A.1......................................... 12 A.2 Compare............................................ 14 A.3........................................ 23 A.4..................................... 25

1 [1,2] [3] Battle Ship Battle Ship 2 3 Battle Ship 4 Battle Ship Compare 5 6 7 8 1

2 Battle Ship ( ) Battle Ship 2.1 2.2 Battle Ship 2

3 Battle Ship Battle Ship 3.1 Battle Ship [4]( : [3] ) 2 10 10 1 3.2 Battle Ship 3 3.2.1 Practice 3.2.2 Verification 3.2.3 Score 100 3.3 Battle Ship 3

4 Compare Battle Ship Compare Score Compare 1 Compare 2 1 Compare.c 4

2 Compare 5

5 Battle Ship 5.1 Battle Ship 5.2 Battle Ship Battle Ship 3 Score 4 3 6

4 Score 7

6 Battle Ship Battle Ship Battle Ship 1 8

7 Battle Ship 9

8 Battle Ship Battle Ship 8.1 8.2 1 8.3 Battle Ship terminal terminal terminal GUI 5 5 Battle Ship play 10

[1].. 2009. [2].. 2011. [3] - wikipedia. http://ja.wikipedia.org/wiki/ #.E3.83.AC.E3.83.BC. E3.83.80.E3.83.BC.E4.BD.9C.E6.88.A6.E3.82.B2.E3.83.BC.E3.83.A0. [4] Battleship (game). http://en.wikipedia.org/wiki/battleship_(game). 11

A A.1 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) int a=0; char buff[64],number[16]; char *login = getlogin(); while(a!= 9) printf("\nmode select\n1:practice 2:Verification 3:Score 4.Compare 9:Quit\n"); scanf("%d",&a); switch(a) case 1: system("./practice"); break; case 2: sprintf(buff,"gcc -o %s function.o verification.o %s.c",login,login); system(buff); sprintf(buff,"./%s",login); system(buff); break; case 3: sprintf(buff,"gcc -o %s function.o score.o %s.c",login,login); system(buff); sprintf(buff,"./%s",login); 12

system(buff); break; case 4: sprintf(buff,"gcc -o %s function.o compare.o name_entry.o %s.c",login,login); system(buff); sprintf(buff,"./%s",login); system(buff); break; default: break; return; 13

A.2 Compare #include <stdio.h> #include <stdlib.h> #include <time.h> #include "senkan.h" char line[100]; void haichi (); void dispsb (); int zanteki (); void shoot (); int meichup (); int meichud (); int tsb[10][10], sb[10][10]; int skp = 5, jkp = 4, kkp = 3, smp = 3, ysp = 2; int gx=0, gy=0; int i, kekka, k; int bx, by; int fun_c=0, at_flg=0; int up, rig, dow, lef; float average; int main (void) int j, a, b, total = 0; for (j = 1; j <= 100; j++) skp = 5, jkp = 4, kkp = 3, smp = 3, ysp = 2; fun_c = 0, at_flg = 0; haichi (); for (a = 0; a < 10; a++) for (b = 0; b < 10; b++) sb[a][b] = N; 14

zanteki (); i = 1; for (i = 2; i <= 101; i++) k = meichup (); kekka = meichud (); if (zanteki () i == 101) break; shoot(); i--; total = total + i; printf ("%3d %3d \n", j, i); average = total / 100.0; printf (" %6.2f\n", average); name_entry(average); return 0; void haichi () int tate, yoko, cx, cy; static unsigned int seed = 1; srand ((unsigned int) time (NULL) * seed); for (tate = 0; tate < 10; tate++) for (yoko = 0; yoko < 10; yoko++) tsb[tate][yoko] = N; 15

if (rand () % 2 == 0) /* */ cy = rand () % 10; cx = rand () % 6; tsb[cx][cy] = SK; tsb[cx + 1][cy] = SK; tsb[cx + 2][cy] = SK; tsb[cx + 3][cy] = SK; tsb[cx + 4][cy] = SK; else /* */ cx = rand () % 10; cy = rand () % 6; tsb[cx][cy] = SK; tsb[cx][cy + 1] = SK; tsb[cx][cy + 2] = SK; tsb[cx][cy + 3] = SK; tsb[cx][cy + 4] = SK; if (rand () % 2 == 0) /* */ cy = rand () % 10; cx = rand () % 7; while (tsb[cx][cy]!= N tsb[cx + 1][cy]!= N tsb[cx + 2][cy]!= N tsb[cx + 3][cy]!= N) cy = rand () % 10; cx = rand () % 7; tsb[cx][cy] = JK; tsb[cx + 1][cy] = JK; tsb[cx + 2][cy] = JK; tsb[cx + 3][cy] = JK; else /* */ cx = rand () % 10; cy = rand () % 7; while (tsb[cx][cy]!= N tsb[cx][cy + 1]!= N tsb[cx][cy + 2]!= N tsb[cx][cy + 3]!= N) 16

cx = rand () % 10; cy = rand () % 7; tsb[cx][cy] = JK; tsb[cx][cy + 1] = JK; tsb[cx][cy + 2] = JK; tsb[cx][cy + 3] = JK; if (rand () % 2 == 0) /* */ cy = rand () % 10; cx = rand () % 8; while (tsb[cx][cy]!= N tsb[cx + 1][cy]!= N tsb[cx + 2][cy]!= N) cy = rand () % 10; cx = rand () % 8; tsb[cx][cy] = KK; tsb[cx + 1][cy] = KK; tsb[cx + 2][cy] = KK; else /* */ cx = rand () % 10; cy = rand () % 8; while (tsb[cx][cy]!= N tsb[cx][cy + 1]!= N tsb[cx][cy + 2]!= N) cx = rand () % 10; cy = rand () % 8; tsb[cx][cy] = KK; tsb[cx][cy + 1] = KK; tsb[cx][cy + 2] = KK; if (rand () % 2 == 0) /* */ cy = rand () % 10; cx = rand () % 8; while (tsb[cx][cy]!= N tsb[cx + 1][cy]!= N tsb[cx + 2][cy]!= N) cy = rand () % 10; 17

cx = rand () % 8; tsb[cx][cy] = SM; tsb[cx + 1][cy] = SM; tsb[cx + 2][cy] = SM; else /* */ cx = rand () % 10; cy = rand () % 8; while (tsb[cx][cy]!= N tsb[cx][cy + 1]!= N tsb[cx][cy + 2]!= N) cx = rand () % 10; cy = rand () % 8; tsb[cx][cy] = SM; tsb[cx][cy + 1] = SM; tsb[cx][cy + 2] = SM; if (rand () % 2 == 0) /* */ cy = rand () % 10; cx = rand () % 9; while (tsb[cx][cy]!= N tsb[cx + 1][cy]!= N) cy = rand () % 10; cx = rand () % 9; tsb[cx][cy] = YS; tsb[cx + 1][cy] = YS; else /* */ cx = rand () % 10; cy = rand () % 9; while (tsb[cx][cy]!= N tsb[cx][cy + 1]!= N) cx = rand () % 10; cy = rand () % 9; tsb[cx][cy] = YS; tsb[cx][cy + 1] = YS; 18

seed = rand (); void dispsb () int i, j; printf (" printf (" 1 2 3 4 5 6 7 8 9 10\n"); ---------------------\n"); for (i = 0; i < 10; i++) printf ("%2d", i + 1); for (j = 0; j < 10; j++) putchar ( ); switch (sb[i][j]) case BM: putchar ( O ); break; case BH: putchar ( X ); break; default: putchar ( ); break; printf (" \n"); printf (" ---------------------\n"); int zanteki () if (skp <= 0 && jkp <= 0 && kkp <= 0 && smp <= 0 && ysp <= 0) /* printf(" \n"); */ 19

return 1; /* printf(" "); if(skp > 0) printf(" "); if(jkp > 0) printf(" "); if(kkp > 0) printf(" "); if(smp > 0) printf(" "); if(ysp > 0) printf(" "); putchar( \n ); */ return 0; int meichup () /* x->gx, y->gy change */ int a, b; a = tsb[gx][gy]; b = sb[gx][gy]; if (b!= N) return BH; if (a == SK) sb[gx][gy] = BM; skp--; return SK; if (a == JK) 20

sb[gx][gy] = BM; jkp--; return JK; if (a == KK) sb[gx][gy] = BM; kkp--; return KK; if (a == SM) sb[gx][gy] = BM; smp--; return SM; if (a == YS) sb[gx][gy] = BM; ysp--; return YS; sb[gx][gy] = BH; return BH; int meichud () if (k == BH) return BH; else if (k == SK && skp <= 0) return SK; else if (k == JK && jkp <= 0) return JK; else if (k == KK && kkp <= 0) 21

return KK; else if (k == SM && smp <= 0) return SM; else if (k == YS && ysp <= 0) return YS; return BM; 22

A.3 #include <stdio.h> #include <stdlib.h> #include <string.h> FILE *file; char *score,str[16] ; int i,j,temp; int dist[200] = 0; int main (void) file = fopen("./result.txt", "r"); for(i=1; i<150; i++) while(fgets(str, 16, file)) score = strtok(str, ","); temp = atoi(score); temp = temp / 10; dist[temp]++; break; printf(" \n"); for(i=0;i<10;i++) if(i<4) dist[4] += dist[i]; else if(i>4) printf("%d ~ %d :\t",i*10,i*10+9); for(j=0;j<dist[i];j++) putchar( * ); 23

printf("\n"); else printf("49 :\t"); for(j=0;j<dist[i];j++) putchar( * ); printf("\n"); fclose(file); return 0; 24

A.4 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> FILE *temp,*file; int i; float x; char str[16]; char *pt,*student; int name_entry (float average) file = fopen("./result.txt","r"); temp = fopen("./temp.txt", "a"); for(i=0; i<255; i++) while(fgets(str, 16, file)) if(strstr(str,student)) fputs(str,temp); else pt = strtok(str,","); x = atof(pt); if(average < x) printf("new RECORD!\tNEW:%2.2lf\tOLD:%2.2lf\n",average,x); fprintf(temp,"%2.2lf,%s\n",average,student); fclose(file); fclose(temp); system("cp temp.txt result.txt && rm temp.txt"); 25

return 0; 26