untitled

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

file:///D|/C言語の擬似クラス.txt

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

(STL) STL 1 (deta structure) (algorithm) (deta structure) 2 STL STL (Standard Template Library) 2.1 STL STL ( ) vector<int> x; for(int i = 0; i < 10;

design_pattern.key

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 UNIX C ( ) 4 1 HTML 1

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

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

: : : TSTank 2

Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3

cpp1.dvi

JavaプログラミングⅠ

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

cpp4.dvi

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

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

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

8 / 0 1 i++ i 1 i-- i C !!! C 2

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

oop1

新版明解C言語 実践編

main

PowerPoint Presentation


P06.ppt

1 CUI CUI CUI 1.1 cout cin redirect.cpp #i n c l u d e <s t r i n g > 3 using namespace std ; 5 6 i n t main ( void ) 7 { 8 s t r i n g s ; 10 c

Condition DAQ condition condition 2 3 XML key value

1_cover

1.3 ( ) ( ) C

新・明解C言語 実践編

num9.dvi

PowerPoint Presentation

exec.dvi

I java A

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

Cプログラミング - 第8回 構造体と再帰

1 1.1 *1 1. sep1.cpp main() sep.cpp separate() *1 GNOME KDE 3

PowerPoint プレゼンテーション

K227 Java 2

WinHPC ppt

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

2008chom.pdf

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flow

新版 明解C++入門編

プログラミング基礎I(再)

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

Microsoft PowerPoint pptx

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

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

問題 01 水道料金を節約しよう 問題のポイント問題文で述べられた仕様を理解し その通りに動作するプログラムを記述できるかを問う問題です 変数 入出力 四則演算に加え 条件分岐や繰り返し処理についての知識が必要です 問題の解き方いくつかのアルゴリズムが考えられますが w が 100 以下と小さい値な

untitled

untitled

tomo_sp1

untitled

2. (297) 91 (365) (366) (371) (673) (938) (64) 85 (91) (631) (561) (302) (616) 63 (906) 68 (338) (714) (747) (169) (718) 62 (1,063) 67 (714) (169) (90

2. (1,009) 45 (368) (226) (133) (54) (260) 25 (446) 30 (774) (156) (805) (244) (652) 22 (128) (652) (157) (597) (805) (446) 30 (774) 35 (238) (581) (1

programmingII2019-v01

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

Microsoft PowerPoint ppt

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

ALG2012-A.ppt

1.ppt

目 目 用方 用 用 方

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

C 言語経験者のための C++ 入門

_CS4.indd

明解Javaによるアルゴリズムとデータ構造

P05.ppt

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

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

ex01.dvi

(Version: 2017/4/18) Intel CPU 1 Intel CPU( AMD CPU) 64bit SIMD Inline Assemler Windows Visual C++ Linux gcc 2 FPU SSE2 Intel CPU do

untitled

text_08.dvi

r07.dvi

MPI MPI MPI.NET C# MPI Version2

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

ohp07.dvi

阪神5年PDF.PDF

12 1


Microsoft Word - 01_表紙

第4回 小平市の文化振興を考える市民委員会

<4D F736F F D2089AB93EA8CA48F43838C837C815B83675F8FAC97D1>

2

渋谷区耐震改修促進計画

2

Microsoft Word - 第8回問題(3級)


1,000m 875m1 6km

Ⅰ.市区町村事例ヒアリング結果の詳細

一太郎 13/12/11/10/9/8 文書

Microsoft Word - NEWホノルル.docx

私にとっての沖縄と独自性.PDF

00.pdf

Microsoft Word - P01_導水路はいらない!愛知の会 会報11号-1 .docx



Transcription:

C++2 1. publicprivate 2. 3. 4. 5. Intelligent Electronic Systems Group protected Carmainmy_car.car_number ca_number //Car class Car int car_number; // void showgas( ); // double gas; // void shownumber( ); // ; //Car void Car::showNumber( ) std::cout << << car_number << n ; void Car::showGas( ) std::cout << << gas << n ; int main( ) my_car.car_number = 4126; my_car.gas = 45.8; my_car.shownumber( ); my_car.showgas( ); // // // // // main main

#include<iostream> // class mycls int value; // void setvalue( int n ); // // ; void mycls::setvalue(int n) if( n > 0 ) value = n; else std::cout<<" n"; #include<iostream> // class mycls int value; // ; valuesetvalue() setvalue // value Car( ) ~ ~Car( ) void

#include<iostream> 01000 0100 //Car class Car ; int car_number; double gas; // // Car( ); // void shownumber( ); // void showgas( ); // void setnumber( int n ); // void setgas( double g ); // int getnumber( ) return car_number; // double getgas( ) return gas; // //Car Car::Car( ) // car_number = 0; gas = 0.0; void Car::showNumber( ) std::cout << << car_number << n ; void Car::showGas( ) std::cout << << gas << n ; if ( gas < 1.0 ) std::cout << n ; void Car::setNumber( int n ) if( n >= 0 && n <=1000 ) car_number = n; else std::cout << n ; void Car::setGas( double g ) if( g >= 0 && g <=100 ) gas = g; else std::cout << n ; int main( ) Car your_car; // //() my_car.setnumber( 4126 ); // my_car.setgas( 45.8 ); // your_car.setnumber( 2981 ); // your_car.setgas( 0.0 ); // my_car.shownumber( ); // my_car.showgas( ); // your_car.shownumber( ); // your_car.showgas( ); // // //shownumbershowgas // std::cout << << my_car.getnumber( ) << n ; // p12-1.cpp

pld(currentload) 2 Car Car Truck class ; ; Truck //Car class Car int car_number; // double gas; // Car( ); // void shownumber( ); // void showgas( ); // void setnumber( int n ); // void setgas( double g ); // int getnumber( ) return car_number; // double getgas( ) return gas; // ; //Truck class Truck : public Car double pld; // double CurrentLoad; // double getpld() return pld; double getcurrentload return CurrentLoad; void setpld( double value ); void setcurrentload( double value); ; void Truck::setPLD( double value ) pld = value; void Truck::setCurrentLoad( double value) if(value <= pld) CurrentLoad =value; else std::cout<<" n";

Truck Truck Car public private private car_numbergas public protected protected Before After Truckcar_numbergas protected private class : Truckpublic

public public public public protected protected private private private= TruckshowNumber() shownumbertruck()

//Truck class Truck : public Car void shownumber(); ; // void Truck::showNumber() std::cout << << car_number << n ; std::cout << n ; class, ;

(Q)std::cout"std::" (A)stdcout C++ :: using namespace std; cout << "hogehoge! n" using namespace #include <iostream> using namespace std; //std int main() cout << "std:: n"; #include <iostream> namespace MySpace // class Mcls // ; // ; MySpace MySpaceMcls int main() () MySpace::Mcls m_cls; #include <iostream> namespace MySpace // class Mcls // ; // ; using namespace MySpace; int main() Mcls m_cls; MySpace MySpace:: 11-2.cpp Car cars[10]; Car 10

//Car class Car int car_number; double gas; void shownumber( ); void showgas( ); void run( double distance); ; // // // // // //Car //Car void Car::showNumber() std::cout << "" << car_number << " n"; //Car void Car::run( double distance ) //10km gas = gas -distance/10.0; if(gas < 0) gas = 0; std::cout << " n"; int main( ) int i; Car cars[3]; //3 for(i=0; i<3; i++) cars[i].car_number = 1000+i; // cars[i].gas = i*10; // for(i=0; i<3; i++) cars[i].shownumber( ); // for(i=0; i<3; i++) cars[i].run( i ); // i (km) cars[i].showgas( ); // p12-2.cpp p12-2.cpp G: paperwork >bcc32 p12-2.cpp Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland p11-1.cpp: Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland G: paperwork >p12-2 1000 1001 1002 0 9.9 19.8 G: paperwork >

Car* p_car; p_car = &my_car; //Car //Car // hoge &hoge[0] hoge *hoge hoge[0] *(hoge+i)hoge[i] p12-2.cpp int main( ) int i; Car cars[2]; Car* my_car; Car* your_car; //2 // // my_car = cars; // your_car = cars+1; // for(i=0; i<2; i++) cars[i].car_number = 1000+i; // (*my_car).shownumber( ); // cars[0].shownumber() (*your_car).shownumber( ); // p12-3.cpp (*my_car).shownumber( ); my_car->shownumber( ); int main( ) int i; Car cars[2]; Car* my_car; Car* your_car; //2 // // my_car = cars; your_car = cars+1; for(i=0; i<2; i++) (cars+i)->car_number = 1000+i; my_car->shownumber( ); your_car->shownumber( ); // // // // // p12-4.cpp

//Car void runandshow(car m_car, double dist); // int main(void) my_car.car_number=1000; my_car.gas=50; runandshow(my_car, 10); // // // void runandshow(car m_car, double dist) m_car.run(dist); // m_car.showgas(); // p12-5.cpp //Car void runandshow(, double dist); // int main(void) my_car.car_number=1000; my_car.gas=50; runandshow(, 10); void runandshow(, double dist) // // // // // //Car void runandshow( Car* p_car, double dist); // int main(void) // my_car.car_number=1000; my_car.gas=50; // runandshow( &my_car, 10); // void runandshow( Car* p_car, double dist) p_car->run( dist); // p_car->showgas(); // p12-6.cpp