untitled

Similar documents
プログラミング演習 土曜日(Q組)

C 資料 電脳梁山泊烏賊塾 ファイルの入出力 C++ のファイル入出力 初めに 此処では Visual Studio 2017 を起動し 新しいプロジェクトで Visual C++ の Windows デスクトップを選択し Windows コンソールアプリケーションを作成する 使用クラ

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

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

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

基礎プログラミング2015

新・明解C言語 実践編

# 深く掘り下げる C++ 講座 < 第 2 回 > // 先に先週の内容の解説 r ( キャリッジリターン ) 行の先頭に戻る 語源はタイプライターからだそうです とりあえず 以下に rを使ったくるくる回る顔文字のソース 注 : 以下のソースはmacのターミナル上での動作のみ保証 例 ) #inc

P05.ppt

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

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

新版明解C言語 実践編

情報処理演習 B8クラス

超初心者用

ファイル入出力

PowerPoint Presentation

C言語入門

ファイル入出力

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

計算機プログラミング

卒 業 研 究 報 告.PDF

1. ファイルにアクセスするには ファイルにアクセスするには 1. ファイルを開く 2. アクセスする 3. ファイルを閉じるという手順を踏まなければなりません 1.1. ファイルを読み込む まずはファイルの内容を画面に表示させるプログラムを作りましょう 開始 FILE *fp char fname

02: 変数と標準入出力

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

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

プログラミング基礎

02: 変数と標準入出力

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

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

ソフトゼミC 第二回 C++の基礎

スライド タイトルなし

PowerPoint プレゼンテーション

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

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

tuat2.dvi

‚æ4›ñ

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

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

第7章 有限要素法のプログラミング

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

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

Microsoft Word - no15.docx

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

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

C 資料 電脳梁山泊烏賊塾 ファイルの入出力 C++ のバイナリファイル入出力 初めに 此処では Visual Studio 2017 を起動し 新しいプロジェクトで Visual C++ の Windows デスクトップを選択し Windows コンソールアプリケーションを作成する

Cプログラミング1(再) 第2回

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

C言語講座 ~ファイル入出力編~

comment.dvi

tuat1.dvi

1 4 2 EP) (EP) (EP)

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

double float

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

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

Microsoft Word - 06

ディジタル信号処理

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

P6dark P6dark µ-pic 2 µ-pic 2 3 µ-pic µ-pic µ-pic 3 µ-pic (10cm ) MPGC N3035-KA195 No. SN ASD (16ns[C]) (16nsC

目次

プログラミング基礎

練習&演習問題

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

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

PowerPoint Presentation

1.ppt

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

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

ohp08.dvi

ディジタル信号処理

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

P02.ppt

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

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

untitled

program.dvi

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

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

データ構造

BW BW

Microsoft PowerPoint - 第3回目.ppt [互換モード]

基礎プログラミング2015

C プログラミング演習 1( 再 ) 2 講義では C プログラミングの基本を学び 演習では やや実践的なプログラミングを通して学ぶ

関数の呼び出し ( 選択ソート ) 選択ソートのプログラム (findminvalue, findandreplace ができているとする ) #include <stdio.h> #define InFile "data.txt" #define OutFile "sorted.txt" #def

joho07-1.ppt

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf ("sum=%d n",sum); 2

gengo1-12

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

memo

Microsoft PowerPoint - prog04.ppt

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

+ +

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 - no204.docx

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

フローチャートの書き方

ポインタ変数

gengo1-12

ゲームエンジンの構成要素

Transcription:

Q 8 1

8.1 (C++) C++ cin cout 5

C++ 16 6

p.63 8.3 #include <iomanip> 7

showbase noshowbase showpoint noshowpoint 8.3 uppercase 16 nouppercase 16 setfill(int) setprecision(int) setw(int) setbase(int) dec 10 hex 16 oct left right fixed scientific flush ends endl unitbuf nounitbuf 8 10 skipws noskipws #include <iomanip> ws 8

001 #include <iostream> 002 #include <iomanip> 23 iostream iomanip 003 int main ( void ) { (<<) 004 std:: cout << std:: hex << std:: setw(8) 005 << std:: setfill ( # ) << 1234 << std:: endl; 006 return 0; 007 } 9

eof() EOF(end EOF( d of file) true fail() I/O true bad() true good() true true clear() if (cin.fail()) 10

8.2 (C++) #include <fstream> 3 ifstream fin; ofstream fout; fstream fboth; ifstream ofstream fstream 11

001 002 003 24 #include <fstream> #include <string> int main (void) { std :: ifstream infile; std :: ofstream outfile; infile.open( file1 ); outfile.open( file2 ); std :: string s; while( getline(infile,s)){ outfile << s << std :: endl; } infile.close( (); outfile.close( ); return 0; } fstream 004 005 006 007 008 009 010 011 012 013 014 015 string s 24 11 12

in out app ate trunc binary 13

25 001 #include <fstream> fstream 002 003 004 int main (void){ std :: ifstream file; file.open( open( file1 ); 005 006 // file1 file.close( ); file.clear( ); 008 file.open( file2 ); 009 //file2 010 file.close( ); 011 return 0; 012 } 2 007 14

8.3 string (C++) #include <sstream> istringstream ostringstream stringstream string istream string ostream string iostream istringstream ostringstream stringstream string 15

8.4 (C) printf printf( i,... ); % printf("%d %f %c", 2*10, 10.0/5.0, '1'); 20 2.000000 1 printf("%+5 %+5.2f 2f", 10.0/5.0); 0/5 0); +2.00 printf("%a", 1.0/10); printf("system %s Engineering", "Design"); 0x1.999999999999ap 4 System DesignEngineering 16

8.4 (C) scanf scanf(,... ); float 20 2.000000 1 scanf("%d %f %c", &i, &f, &c); +2.00 200 scanf("%+5.2lf", &d); 0x1.999999999999ap 4 scanf("%la", &d); System Design Engineering scanf("system %s Engineering", s); 17

8.4 (C) puts, fputs puts( ); fputs(, ); puts("hello n"); fputs("hello n", stdout); fgets, fgets gets( ); fgets(,, ); char s[100]; gets(s); fgets(s, 100, stdin); 18

8.5 (C) FILE <stdio.h> h FILE fp ; 1. 2. 3. 19

FILE *fopen(char *filename, char *mode) w: a: r: r+, w+, a+ : rb, wb, ab: fp=fopen( data.txt, r ); int fclose(file *fp) i= fclose(fp); int fprintf(file *fp,char *format,..... ) fprintf(fp, Hello %d n,i); int fscanf(file *fp,char *format,..... ) fscanf(fp, %d,&i);

26 001 #include <stdio.h> 002 int main(void) { 003 int age; 004 float height; 005 char name[40]; 006 FILE *fp; 007 if ((fp = fopen("personal.txt","w")) == NULL){ 008 fprintf(stderr, File open failed. n"); 009 return 1; 010 } 011 while(1){ 012 printf( Input age height name: n"); 013 if (scanf("%d %f %s",&age,&height,name)<3) 014 break; 015 fprintf(fp,"%d %f %s n",age,height,name); 016 } 017 fclose(fp); 018 return (0); 019 }

26 001 #include <stdio.h> 002 int main(void) { 003 int age; 004 float height; 005 char name[40]; 006 FILE *fp; 007 if ((fp = fopen("personal.txt","w")) == NULL){ 008 fprintf(stderr, File open failed. n"); 009 return 1; 010 } 011 while(1){ 012 printf( Input age height name: n"); 013 if (scanf("%d %f %s",&age,&height,name)<3) 014 break; 015 fprintf(fp,"%d %f %s n",age,height,name); 016 } 017 fclose(fp); 018 return (0); 019 }

26 001 002 #include <stdio.h> int main(void) { stdio.h 003 005 int age; char name[40]; 004 006 float height; FILE *fp; 007 if ((fp = fopen("personal.txt","w")) == NULL){ 008 fprintf(stderr, File open failed. n"); 009 return 1; 010 } 011 while(1){ 012 printf( Input age height name: n"); 013 if (scanf("%d %f %s",&age,&height,name)<3) 014 break; 015 fprintf(fp,"%d %f %s n",age,height,name); 016 } fclose(fp); return (0); 017 018 019 }

8.6 int sprintf(char *sp, char *format,...) sprintf(sp, "Hello %d n", i); int sscanf(char *sp, char *format,...) sscanf(sp, "%d", &i); 24

8.1 8.7 1. 2. 25