cpp4.dvi

Size: px
Start display at page:

Download "cpp4.dvi"

Transcription

1 2017 c 4 C++ (4) C++, 41, 42, 1, 43,, 44 45, 41 (inheritance),, C++,, 100, 50, PCMCIA,,,,,,,,, ( ), car 1 [List 41] 1: class car { 2: private: 3: std::string m model; // 4: std::string m maker; // 5: int m displacement; // 6: int m ps; // 7: int m weight; // 8: public: 9: [List 42] 10: }; 4 1

2 [List 41], m g, ++,,!? 2, [List 42] 1: car() {} 2: 3: car(const std::string& md, const std::string& mk, int dp, int p, int w): 4: m model(md), m maker(mk), m displacement(dp), m ps(p), m weight(w) {} 5: 6: car() {} 7: 8: std::string model() const {return m model;} // 9: 10: int no() const { // : if (m displacement<2000) return 5; 12: else return 3; 13: } 14: 15: double pwratio() const { // 16: return (double) m weight/(double) m ps; 17: } 18: 19: int tax() const { // 20: if (m displacement<=1000) return 29500; 21: else if (m displacement<=1500) return 34500; 22: else if (m displacement<=2000) return 39500; 23: else if (m displacement<=2500) return 45000; 24: else if (m displacement<=3000) return 51000; 25: else if (m displacement<=3500) return 58000; 26: else if (m displacement<=4000) return 66500; 27: else if (m displacement<=4500) return 76500; 28: else if (m displacement<=6000) return 88000; 29: else return ; 30: } 3 4 2

3 [List 43] 1: int main(void) { 2: 3: car a = car("skyline", "Nissan", 3498, 272, 1500); 4: car b = car("civic", "Honda", 1998, 215, 1190); 5: 6: std::cout << amodel() << " " 7: << ano() << " " 8: << apwratio() << " " 9: << atax() << std::endl; 10: 11: std::cout << bmodel() << " " 12: << bno() << " " 13: << bpwratio() << " " 14: << btax() << std::endl; 15: 16: return 0; 17: }, Skyline Civic ( ) car, hybrid car car, 1 int m motor ps 2 pwratio() ( ) 3 tax() ( ) 3, car, 1, car class hybrid car class hybrid car : car, hybrid car car, (base class), (derived class), car hybrid car, (superclass), (subclass) [List 44] 1: class hybrid car : public car { // public 2: private: 3: int m motor ps; 4: public: 5: [List 45] 6: }; 4 3

4 2, [List 44], m motor ps, car 5 m motor ps 1 public, car public, private, 3,, ( overwrite ( ) ) [List 45] 1: hybrid car() {} 2: 3: hybrid car(const std::string& md, const std::string& mk, 4: int dp, int p, int w, int mps): 5: car(md,mk,dp,p,w), m motor ps(mps) {} 6: 7: hybrid car() {} 8: 9: double pwratio() const { // 10: return (double) m weight/(double)(m ps+m motor ps); 11: } 12: 13: int tax() const {return 0;} // ( ) 4 car 1 ( ), private, ( public ), (, ), private protected [List 46] 1: class car { 2: protected: 3: std::string m model; // 4: std::string m maker; // 5: int m displacement; // 6: int m ps; // 7: int m weight; // 8: public: 9: [List 42] 10: } 5 [List 43] 4 4

5 [List 47] 1: int main(void) { 2: 3: car a = car("skyline", "Nissan", 3498, 272, 1500); 4: car b = car("civic", "Honda", 1998, 215, 1190); 5: hybrid car h = hybrid car("prius", "Toyota", 1496, 77, 1290, 68); 6: 7: std::cout << amodel() << " " 8: << ano() << " " 9: << apwratio() << " " 10: << atax() << std::endl; 11: 12: std::cout << bmodel() << " " 13: << bno() << " " 14: << bpwratio() << " " 15: << btax() << std::endl; 16: 17: std::cout << hmodel() << " " 18: << hno() << " " 19: << hpwratio() << " " 20: << htax() << std::endl; 21: 22: return 0; 23: }, Skyline Civic Prius [List 44] [List 47], [List 41] [List 43] 423, hybrid car tax(),, int tax() const {return car tax() /2;}, car tax(), C++ car::tax() 42 hybrid car tax(), 424 /,, 4 5

6 [List 45] 1 hybrid car,, hybrid car [List 45] 2,,, 43 car, hybrid car,, [List 47],, [List 47] hybrid car, 43 2 C++, stack ( ) stack 3 ( ) stack ac, int n push(), void push() int n pop(), void pop() stack ac stack, push int count (, pop count ),, private void push(int), stack void push(int), push count 1 int n push(), push count void pop(),,sp push count (, sp stack sp private protected, sp, size(), ),, / 44 stack ac, stack, main(void) stack ac stack, stack 1,, stack,, STL, vector, [] 7 ( 1 C++ [ 3 ] p 86;, template ) 4 6

7 44 3,,,,,,, (canvas), (point), (rectangle), (diamond) (main) [List 48] 1: #include <iostream> 2: inline int abs(int x) {return 0<=x? x : -x;} 3: // 4: 5: [canvas ] 6: [point ] 7: [rectangle ] 8: [diamond ] 9: 10: [main ] g++, abs(int), include, abs(int), 2 canvas 2 (, X ) [List 49] 1: class canvas { 2: public: 3: canvas(int sx, int sy); // sx sy 4: canvas(); // 5: void clear(); // 6: void set(int x, int y); // (x,y) 7: void print(std::ostream &os); // 8: private: 9: int size x; // ( ) 10: int size y; // ( ) 11: char **p; // 2 12: canvas(const canvas&); // 13: canvas& operator=(const canvas&); // 14: }; 4 7

8 <<, 15: std::ostream& operator<<(std::ostream& os, canvas& c) {cprint(os);} canvas(int, int) size x, size y, new [List 410] 1: canvas::canvas(int sx, int sy): size x(sx), size y(sy) { 2: p = new char*[size x]; 3: for (int x=0; x<size x; x++) p[x] = new char[size y]; 4: this->clear(); // canvas::clear() 5: } canvas(), [List 411] 1: canvas:: canvas() { 2: for (int x=0; x<size x; x++) delete [] p[x]; 3: delete [] p; 4: } canvas::clear() [List 412] 1: void canvas::clear() { 2: for (int x=0; x<size x; x++) { 3: for (int y=0; y<size y; y++) { 4: p[x][y] = ; 5: } 6: } 7: } canvas::set(int, int) X, [List 413] 1: void canvas::set(int x, int y) { 2: if (0<=x && x<size x && 0<=y && y<size y) p[x][y] = X ; 3: } canvas::print(std::ostream&) (0,0) 4 8

9 [List 414] 1: void canvas::print(std::ostream& os) { 2: os << + ; 3: for (int x=0; x<size x; x++) {os << - ;} 4: os << + << std::endl; 5: for (int y=size y-1; 0<=y; y--) { 6: os << ; 7: for (int x=0; x<size x; x++) { 8: os << p[x][y]; 9: } 10: os << << std::endl; 11: } 12: os << + ; 13: for (int x=0; x<size x; x++) {os << - ;} 14: os << + << std::endl; 15: } point 1 [List 415] 1: class point { 2: private: 3: int px, py; // 4: public: 5: point(int x, int y); // (x,y) 6: point(); 7: void move(int ix, int iy); // x ix, y iy 8: void draw(canvas &c); // c 9: }; [List 416] 1: point::point(int x, int y) : px(x), py(y) {} 2: point:: point() {} 3: void point::move(int ix, int iy) {px += ix; py += iy;} 4: void point::draw(canvas &c) {cset(px,py);} rectangle 4 9

10 [List 417] 1: class rectangle { 2: private: 3: int px, py; 4: int width, height; // 5: public: 6: rectangle(int x, int y, int w, int h); 7: // (x,y), w, h 8: rectangle(); 9: void move(int ix, int iy); // x ix, y iy 10: void draw(canvas &c); // c 11: }; 45 diamond [List 418] 1: class diamond { 2: private: 3: int px, py; 4: int radius; // ( ) 5: public: 6: diamond(int x, int y, int r); 7: diamond(); 8: void move(int ix, int iy); 9: void draw(canvas &c); 10: }; [List 419] 1: diamond::diamond(int x, int y, int r) : px(x), py(y), radius(r) {} 2: diamond:: diamond() {} 3: void diamond::move(int ix, int iy) {px += ix; py += iy;} 4: void diamond::draw(canvas &c) { 5: if (0<=radius) { 6: for (int r=-radius; r<=radius; r++) { 7: int h = radius - abs(r); 8: for (int s=-h; s<=h; s++) { 9: cset(px+r,py+s); 10: } 11: } 12: } 13: } 4 10

11 (3 9 ) 2 c, (11 19 ) 3,, (4,2) (21 27 ) 4 c,,, (29 37 ) [List 420] 1: int main(void) { 2: 3: point p1(0,0); 4: point p2(17,9); 5: point p3(19,2); 6: rectangle r1(2,1,3,2); 7: rectangle r2(7,7,6,2); 8: diamond d1(2,7,2); 9: diamond d2(15,3,4); 10: 11: canvas c(20,10); 12: p1draw(c); 13: p2draw(c); 14: p3draw(c); 15: r1draw(c); 16: r2draw(c); 17: d1draw(c); 18: d2draw(c); 19: std::cout << c; 20: 21: p1move(4,2); 22: p2move(4,2); 23: p3move(4,2); 24: r1move(4,2); 25: r2move(4,2); 26: d1move(4,2); 27: d2move(4,2); 28: 29: cclear(); 30: p1draw(c); 31: p2draw(c); 32: p3draw(c); 33: r1draw(c); 34: r2draw(c); 35: d1draw(c); 36: d2draw(c); 37: std::cout << c; 38: 39: return 0; 40: }, 4 11

12 X X XXX XXXXXX XXXXX XXXXXX X XXX XXX X XXXXX XXXXXXX XXXXXXXXX XXX XXXXXXXX XXX XXXXX X XXX XXXXX XXXXXX X XXX XX X XXX XXXX XXXXX XXX XXXX XXX XXX X XX X [List 48] [List 420] rectangle point diamond 442, (1) (, ), draw(canvas &c),move(int,int), (2) move,?, px, py,,,,,, int a[7] a, a[0]=3;, a[1] = "Nagisa"; ( ), C++, rectangle *a[7], a[1] = new diamond(2,7,2); cast ( ),,, 443, obj 4 12

13 1 point, rectangle, diamond obj, 3, 2 point, rectangle, diamond obj 3 (a),,, (, ), point, rectangle, diamond, obj, 3 (b), move obj,, point, rectangle, diamond, obj, obj obj, px, py,, type, "point", "rectangle", "diamond", obj, move(int,int), draw(canvas&) obj [List 421] 1: class obj { 2: public: 3: obj(int x, int y, const std::string& t); // 4: obj(); // 5: void move(int ix, int iy); 6: void draw(canvas &c); 7: public: 8: int px, py; 9: std::string type; // "point", "rectangle", "diamond" 10: }; obj [List 422] 1: obj::obj(int x, int y, const std::string& t) : px(x), py(y), type(t) {} 2: obj:: obj() {} 3: void obj::move(int ix, int iy) {px += ix; py += iy;} draw(canvas&), obj 4 13

14 point, rectangle, diamond point obj obj, [List 423] 1: class point : public obj { //obj 2: public: 3: point(int x, int y); // 4: point(); // 5: void draw(canvas &c); // 6: }; point [List 424] 1: point::point(int x, int y) : obj(x, y, "point") {} 2: point:: point() {} 3: void point::draw(canvas &c) {cset(px,py);} 46 rectangle, diamond, 444, main, vector [List 425] 1: int main(void) { 2: std::vector<obj*> vec; 3: 4: // 5: vecpush back(new point(0,0)); 6: vecpush back(new point(17,9)); 7: vecpush back(new point(19,2)); 8: vecpush back(new rectangle(2,1,3,2)); 9: vecpush back(new rectangle(7,7,6,2)); 10: vecpush back(new diamond(2,7,2)); 11: vecpush back(new diamond(15,3,4)); 12: 13: canvas c(20,10); 14: // 15: for (int i=0; i<vecsize(); i++) vec[i]->draw(c); 16: std::cout << c; 17: 18: // 19: for (int i=0; i<vecsize(); i++) vec[i]->move(4,2); 20: 4 14

15 21: cclear(); 22: // 23: for (int i=0; i<vecsize(); i++) vec[i]->draw(c); 24: std::cout << c; 25: 26: // delete 27: for (int i=0; i<vecsize(); i++) delete vec[i]; 28: return 0; 29: }, main! draw, vec[i] point point::draw(canvas&)), rectangle rectangle::draw(canvas&),, vec[i]->draw(c) obj::draw(canvas&)!, draw, ( ) (, vec[i] point rectangle, ), vec[i] obj, vec[i]->draw(c) obj::draw(canvas&) 47 [List 420] [List 425],, vec[i] draw main 15 23, [List 426] 1: for (int i=0; i<vecsize(); i++) { 2: if (vec[i]->type == "point") ((point*) vec[i])->draw(c); 3: else if (vec[i]->type == "rectangle") ((rectangle*) vec[i])->draw(c); 4: else if (vec[i]->type == "diamond") ((diamond*) vec[i])->draw(c); 5: } vec[i] obj, point,, vec[i]->idraw point::draw vec[i] point, (pont*) vec[i], string, 48 main 15 23, 4 15

16 draw(canvas&),, vec[i] vec[i]->draw(c), [List 425] C++ obj::draw(canvas&), [List 427] 1: point p(1,3); 2: rectangle r(2,1,3,2); 3: diamond d(7,7,6,2); 4: 5: obj* x; 6: canvas c(20,10); 7: 8: x = &p; x->draw(c); 9: x = &r; x->draw(c); 10: x = &d; x->draw(c);, x obj, x->draw(c), 8 point::draw(canvas&) 9 rectanble::draw(canvas&) 10 diamond::draw(canvas&) obj::draw, obj draw(canvas&) virtual (9 ) [List 428] 1: class obj { 2: public: 3: obj(int x, int y, const std::string& t); 4: obj(); 5: void move(int ix, int iy); 6: virtual void draw(canvas &c) = 0; 7: public: 8: int px, py; 9: std::string type; 10: }; obj draw(canvas&), = 0 draw(canvas&), obj ( ) 452, 4 16

17 [List 429] 1: class obj { 2: public: 3: obj(int x, int y, const std::string& t); 4: virtual obj(); 5: void move(int ix, int iy); 6: virtual void draw(canvas &c) = 0; 7: public: 8: int px, py; 9: std::string type; 10: }; [List 425] delete vec[i], vec[i] vec[i] point point, obj(), obj() obj(),, point(), obj() point(), (chaining), point() obj() 49 obj::draw(canvas&) obj:: obj(), [List 425] main, ( ) dynamic dispatch, ( ) dynamic dispatch, C++,, dynamic dispatch C C++,, Nagisa ISHIURA 4 17

cpp1.dvi

cpp1.dvi 2017 c 1 C++ (1) C C++, C++, C 11, 12 13 (1) 14 (2) 11 1 n C++ //, [List 11] 1: #include // C 2: 3: int main(void) { 4: std::cout

More information

untitled

untitled http://www.mofa.go.jp/mofaj/toko/visa/index.html http://www.cn.emb-japan.go.jp/jp/01top.htm http://www.shanghai.cn.emb-japan.go.jp/ http://www.guangzhou.cn.emb-japan.go.jp/ http://www.shengyang.cn.emb-japan.go.jp/jp/index.htm

More information

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

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 >> 1 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout

More information

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

(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; (STL) STL 1 (deta structure) (algorithm) (deta structure) 2 STL STL (Standard Template Library) 2.1 STL STL ( ) vector x; for(int i = 0; i < 10; ++i) x.push_back(i); vector STL x.push_back(i) STL

More information

design_pattern.key

design_pattern.key #include void init(int* ary, int size) for (int i = 0; i < size; ++i) ary[i] = i; void mul10(int* ary, int size) for (int i = 0; i < size; ++i) ary[i] *= 10; void dispary(int* ary, int size)

More information

Java学習教材

Java学習教材 Java 2016/4/17 Java 1 Java1 : 280 : (2010/1/29) ISBN-10: 4798120987 ISBN-13: 978-4798120980 2010/1/29 1 Java 1 Java Java Java class FirstExample { public static void main(string[] args) { System.out.println("

More information

text_08.dvi

text_08.dvi C 8 12 6 6 8 Java (3) 1 8.1 8 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 8.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

More information

Condition DAQ condition condition 2 3 XML key value

Condition DAQ condition condition 2 3 XML key value Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................

More information

(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

(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 Handy Graphic for Handy Graphic Version 0.5 2008-06-09 1 Handy Graphic Handy Graphic C Handy Graphic Handy Graphic Mac OS X Handy Graphic HgDisplayer Handy Graphic HgDisplayer 2 Handy Graphic 1 Handy Graphic

More information

- - http://168iroha.net 018 10 14 i 1 1 1.1.................................................... 1 1.................................................... 7.1................................................

More information

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2; 5 p.1 5 JPanel (toy example) 5.1 2 extends : Object java.lang.object extends... extends Object Point.java 1 public class Point { // public int x; public int y; Point x y 5.1.1, 5 p.2 5 5.2 Point int Java

More information

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

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 << C++ C C++ 1 C++ C++ C C++ C C++? C C++ C *.c *.cpp C cpp VC C++ 2 C++ C++ C++ [1], C++,,1999 [2],,,2001 [3], ( )( ),,2001 [4] B.W. /D.M.,, C,,1989 C Web [5], http://kumei.ne.jp/c_lang/ 3 Hello World Hello

More information

XX 1 01 234214 X X 1 0 1 2 3 4 2 1 4000 784 0007533 X X 1 0 1 2 3 4 2 1 4000 7 2 3 7 2 3 2 3 2 2 1 6 2 XXX-XXXX X[ 01 111 9416 39 XXX-XXXX 18.50 3.00 15.50 15.50 0.05 18.50 3.00 15.50,984 1 5 uaj39uuy

More information

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

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) 3 5 14 18 21 23 23 24 28 29 29 31 32 34 35 35 36 38 40 44 44 45 46 49 49 50 pref : 2004/6/5 (11:8) 50 51 52 54 55 56 57 58 59 60 61

More information

: : : TSTank 2

: : : TSTank 2 Java (8) 2008-05-20 Lesson6 Lesson5 Java 1 Lesson 6: TSTank1, TSTank2, TSTank3 java 2 car1 car2 Car car1 = new Car(); Car car2 = new Car(); car1.setcolor(red); car2.setcolor(blue); car2.changeengine(jet);

More information

Javaプログラムの実行手順

Javaプログラムの実行手順 戻り値のあるメソッド メソッドには 処理に使用する値を引数として渡すことができました 呼び出し 側からメソッドに値を渡すだけでなく 逆にメソッドで処理を行った結果の値を 呼び出し側で受け取ることもできます メソッドから戻してもらう値のことを もどりち戻り値といいます ( 図 5-4) 図 5-4. 戻り値を返すメソッドのイメージ 戻り値を受け取ることによって ある計算を行った結果や 処理に成功したか失

More information

1.3 ( ) ( ) C

1.3 ( ) ( ) C 1 1.1 (Data Base) (Container) C++ Java 1.2 1 1.3 ( ) ( ) 1. 2. 3. C++ 2 2.1 2.2 2.3 2 C Fortran C++ Java 3 3.1 (Vector) 1. 2. ( ) 3.2 3 3.3 C++ C++ STL C++ (Template) vector vector< > ; int arrayint vector

More information

VALUESTAR Gシリーズをご購入いただいたお客様へ

VALUESTAR Gシリーズをご購入いただいたお客様へ NEC Corporation, NEC Personal Products, Ltd. 2008 XXXXXXXXXXXXXXX XXXX PC-GV XXXXXXX XXXX XXXX XXXXXX XXXX XXXX XXXXXX XXXX XXXX XXXXXX XXX- XXXXX XXXX XXXX XXXXXX XXXX XXXX XXXXXX XXXX XXXX XXXXXX XXXX

More information

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

解きながら学ぶC++入門編 第 1 章 画面 出力 入力 2 問題 1-1 C++ List 1-1p.4 C++ // cout

More information

10K pdf

10K pdf #1 #2 Java class Circle { double x; // x double y; // y double radius; // void set(double tx, double ty){ x = tx; y = ty; void set(double tx, double ty, double r) { x = tx; y = ty; radius = r; // Circle

More information

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

Java演習(4)   -- 変数と型 -- 50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends

More information

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV [email protected] [email protected] http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 12 11 p.1/33 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20

More information

r02.dvi

r02.dvi 172 2017.7.16 1 1.1? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X ( ) 1.2 1 2-0 ( ) ( ) ( ) (12) ( ) (112) (131) 281 26 1 (syntax) (semantics) ( ) 2 2.1 BNF BNF(Backus Normal Form) Joun Backus (grammer) English

More information

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

解きながら学ぶC++入門編 !... 38!=... 35 "... 112 " "... 311 " "... 4, 264 #... 371 #define... 126, 371 #endif... 369 #if... 369 #ifndef... 369 #include... 3, 311 #undef... 371 %... 17, 18 %=... 85 &... 222 &... 203 &&... 40 &=...

More information

I java A

I java A I java 065762A 19.6.22 19.6.22 19.6.22 1 1 Level 1 3 1.1 Kouza....................................... 3 1.2 Kouza....................................... 4 1.3..........................................

More information

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

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 C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................

More information

Java演習(9) -- クラスとメソッド --

Java演習(9)   -- クラスとメソッド -- Java (9) Java (9) Java (9) 3 (x, y) x 1 30 10 (0, 50) 1 2 10 10 (width - 10, 80) -2 3 50 10 (width / 2, 110) 2 width 3 (RectMove4-1.java) import javax.swing.japplet; import javax.swing.timer; import java.awt.graphics;

More information

yacc.dvi

yacc.dvi 2017 c 8 Yacc Mini-C C/C++, yacc, Mini-C, run,, Mini-C 81 Yacc Yacc, 1, 2 ( ), while ::= "while" "(" ")" while yacc 1: st while : lex KW WHILE lex LPAREN expression lex RPAREN statement 2: 3: $$ = new

More information

2 T 1 N n T n α = T 1 nt n (1) α = 1 100% OpenMP MPI OpenMP OpenMP MPI (Message Passing Interface) MPI MPICH OpenMPI 1 OpenMP MPI MPI (trivial p

2 T 1 N n T n α = T 1 nt n (1) α = 1 100% OpenMP MPI OpenMP OpenMP MPI (Message Passing Interface) MPI MPICH OpenMPI 1 OpenMP MPI MPI (trivial p 22 6 22 MPI MPI 1 1 2 2 3 MPI 3 4 7 4.1.................................. 7 4.2 ( )................................ 10 4.3 (Allreduce )................................. 12 5 14 5.1........................................

More information

使いこなす本 ハード編

使いこなす本 ハード編 B3FH-5841-02 NE3/45LK, NE3/45 B3FH-5841-02 FMV-BIBLO NE3/45LK, NE3/45 FMV B I B L O Contents FMV B I B L O C o n t e n t s FMV B I B L O FMV B I B L O C o n t e n t s 11 1 1 2 3 4 5 6 7 8 9! 2 1 2

More information

SystemC言語概論

SystemC言語概論 SystemC CPU S/W 2004/01/29 4 SystemC 1 SystemC 2.0.1 CPU S/W 3 ISS SystemC Co-Simulation 2004/01/29 4 SystemC 2 ISS SystemC Co-Simulation GenericCPU_Base ( ) GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim

More information

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C> 2 次関数のグラフの向きと広がり [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフについて x の係数 aが正のときと負のときでは グラフにどのような違いがあるでしょうか 2 2 y=ax のグラフについて x の係数 aが正のとき 係数 aの値が大きくなるにつれて グラフの広がりはどうなるでしょうか 2 2 y=ax のグラフについて x の係数

More information

新版 明解C++入門編

新版 明解C++入門編 第 1 章画面 出力 入力 C++ C++ C++ C++ C++ C++ C++ C++ #include using C++ C++ C++ main C++ C++ C++ int double char C++ C++ C++ string C++ C++ C++ 21 1-1 C++ 歴史 C++ C++ 歴史 CC with classes Fig.1-1 C C++ Simula 67

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information

新版明解C言語 実践編

新版明解C言語 実践編 2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,

More information

課題

課題 float xball;// 円の中心の X 座標 float yball; // 円の中心の Y 座標 float rball; // 円の半径 color cball; // 円の色 // 円を移動させる void updateball(){ yball -= 1; if(yball+rball< 0){ yball = height+rball; // 円を描く void drawball(){

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

r03.dvi

r03.dvi 19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---

More information

RHEA key

RHEA key 2 P (k, )= k e k! 3 4 Probability 0.4 0.35 0.3 0.25 Poisson ( λ = 1) Poisson (λ = 3) Poisson ( λ = 10) Poisson (λ = 20) Poisson ( λ = 30) Gaussian (µ = 1, s = 1) Gaussian ( µ = 3, s = 3) Gaussian (µ =

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

r08.dvi

r08.dvi 19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev

More information

新・明解C言語 実践編

新・明解C言語 実践編 第 1 章 見 21 1-1 見えないエラー 見 List 1-1 "max2x1.h" a, b max2 List 1-1 chap01/max2x1.h max2 "max2x1.h" #define max2(a, b) ((a) > (b)? (a) : (b)) max2 List 1-2 List 1-2 chap01/max2x1test.c max2 #include

More information

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

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç C (3) if else switch AND && OR (NOT)! 1 BMI BMI BMI = 10 4 [kg]) ( [cm]) 2 bmi1.c Input your height[cm]: 173.2 Enter Input your weight[kg]: 60.3 Enter Your BMI is 20.1. 10 4 = 10000.0 1 BMI BMI BMI = 10

More information

PowerPoint Presentation

PowerPoint Presentation p.130 p.198 p.208 2 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i i < NUM; i++ ) ) if if ( weight[i] > max ) max = weight[i]: if if ( weight[i] < min ) min = weight[i]: weight

More information

Microsoft Word - C言語研修 C++編 3.doc

Microsoft Word - C言語研修 C++編 3.doc 2006/05/10 オブジェクト指向... 3 1 クラスの継承... 3 2 継承の書式... 3 3 protected... 5 4 メンバ関数のオーバーライド... 6 5 クラスの型キャスト... 7 6 仮想関数... 8 2 オブジェクト指向 1 クラスの継承 クラスには 継承 という機能があります 継承とは 既にあるクラスを元に 新しいクラスを作る 機能です 継承元のクラスを 親クラス

More information

ALG2012-A.ppt

ALG2012-A.ppt 21279 ([email protected]) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/212/index.html (, )ε m = n C2 = n ( n 1) / 2 m = n ( n 1) 1 11 11 111 11 111 111 1111 1 1 11 1 11 11 111 4-dimentional

More information

programmingII2019-v01

programmingII2019-v01 II 2019 2Q A 6/11 6/18 6/25 7/2 7/9 7/16 7/23 B 6/12 6/19 6/24 7/3 7/10 7/17 7/24 x = 0 dv(t) dt = g Z t2 t 1 dv(t) dt dt = Z t2 t 1 gdt g v(t 2 ) = v(t 1 ) + g(t 2 t 1 ) v v(t) x g(t 2 t 1 ) t 1 t 2

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅱ 4 回目クラスの機能 (2) コンストラクタ クラス変数 クラスメソッド課題 確認 問題次の各文は正しいか誤っているか答えなさい (1) コンストラクタはメソッドと同様に戻り値をもつ (2) コンストラクタはオブジェクトが生成されると最初に実行される (3) コンストラクタはメソッドと同様にオーバーロードができる (4) コンストラクタは常に public メンバとしなければならない

More information

K227 Java 2

K227 Java 2 1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html

More information

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

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); : : :0757230G :2008/07/18 2008/08/17 1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); private: float num; ;

More information

Abstract Kinect for Windows RGB Kinect for Windows v Kinect for Windows v2

Abstract Kinect for Windows RGB Kinect for Windows v Kinect for Windows v2 Kinect 2014 9 19 IS Report No. 2014092901 Report Medical Information System Laboratory Abstract Kinect for Windows 2012 2 RGB Kinect for Windows v2 2014 7 Kinect for Windows v2 1............................

More information

joho07-1.ppt

joho07-1.ppt 0xbffffc5c 0xbffffc60 xxxxxxxx xxxxxxxx 00001010 00000000 00000000 00000000 01100011 00000000 00000000 00000000 xxxxxxxx x y 2 func1 func2 double func1(double y) { y = y + 5.0; return y; } double func2(double*

More information

SystemC 2.0を用いた簡易CPUバスモデルの設計

SystemC 2.0を用いた簡易CPUバスモデルの設計 SystemC 2.0 CPU CPU CTD&SW CT-PF 2002/1/23 1 CPU BCA UTF GenericCPU IO (sc_main) 2002/1/23 2 CPU CPU CQ 1997 11 Page 207 4 Perl Verilog-HDL CPU / Verilog-HDL SystemC 2.0 (asm) ROM (test.hex) 2002/1/23

More information

橡Pro PDF

橡Pro PDF 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

More information

Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問

Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問 Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問のメソッドを追加する public static void main(string[] args) {

More information

DiMP Users Manual Yuichi Tazaki

DiMP Users Manual Yuichi Tazaki DiMP Users Manual Yuichi Tazaki 3 1 5 2 7 2.1............................. 7 2.2........................... 7 3 DiMP 9 3.1............................... 9 3.2........................... 10 3.3...................................

More information

P05.ppt

P05.ppt 2 1 list0415.c forfor #include int i, j; for (i = 1; i

More information

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

(Eclipse\202\305\212w\202\324Java2\215\374.pdf) C H A P T E R 11 11-1 1 Sample9_4 package sample.sample11; public class Sample9_4 { 2 public static void main(string[] args) { int[] points = new int[30]; initializearray(points); double averagepoint =

More information

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; 19 3!!...... (+) (>) (++) (+=) for while 3.1!! 3.1.1 50 20 20 5 (20, 20) 3.1.1 (1)(Blocks1.java) public class Blocks1 extends JApplet { public void paint(graphics g){ 5 g.drawrect( 20, 20, 50, 20); g.drawrect(

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 2005 7 22 22 (sakai.keiichi@kochi [email protected]) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2005/index.html tech.ac.jp/k1sakai/lecture/alg/2005/index.html f(0) = 1, f(x) =

More information

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 JavaScript (2) 1 JavaScript 1.! 1. 2. 3. DOM 4. 2. 3. Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 (1) var a; a = 8; a = 3 + 4; a = 8 3; a = 8 * 2; a = 8 / 2; a = 8 % 3; 1 a++; ++a; (++

More information

Python C/C++ IPMU IRAF

Python C/C++ IPMU IRAF Python C/C++ IPMU 2010 11 24IRAF Python Swig Numpy array Image Python 2.6.6 swig 1.3.40 numpy 1.5.0 pyfits 2.3 pyds9 1.1 svn co hjp://svn.scipy.org/svn/numpy/tags/1.5.0/doc/swig swig/numpy.i /usr/local/share/swig/1.3.40/python

More information

課題

課題 int starttime_msec; boolean counting = false; size(400,200); smooth(); //font は各自のものに変更してください font = loadfont("serif-48.vlw"); void mouseclicked(){ counting = true; starttime_msec = millis(); int t=0;

More information

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

C言語によるアルゴリズムとデータ構造 Algorithms and Data Structures in C 4 algorithm List - /* */ #include List - int main(void) { int a, b, c; int max; /* */ Ÿ 3Ÿ 2Ÿ 3 printf(""); printf(""); printf(""); scanf("%d", &a); scanf("%d",

More information

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。 解答例 問題 1 変数 a が 3 以上でかつ 7 以下の場合 true と表示し そうでない場合は false と表示するプログラムである public class Prog061004_01 { int a; boolean b; a = Integer.parseInt(buf.readLine()); b = (a >= 3) && (a

More information

1

1 2 章 1 整数を一つ読み込み, その階乗を計算する RAM プログラムを書け f (n) = n! ( n 0) 何でもよい ( n

More information

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

新・明解C言語 ポインタ完全攻略 2 1-1 1-1 /* 1-1 */ 1 int n = 100; int *p = &n; printf(" n %d\n", n); /* n int */ printf("*&n %d\n", *&n); /* *&n int */ printf(" p %p\n", p); /* p int * */ printf("&*p %p\n", &*p); /* &*p int * */ printf("sizeof(n)

More information