Size: px
Start display at page:

Download ""

Transcription

1

2 i

3 char 8bit 3 // 4 template <imsize_t N> 5 class bitset { 6 template <imsize_t > friend class bitset; 7 8 static constexpr imsize_t array_size = ((N - 1) >> 3) + 1; 9 unsigned char x[array_size]; 10 public: 11 constexpr bitset(); 1 bitset(const bitset& b); 13 template <imsize_t N> 14 bitset(const bitset <N>&); 15 bitset(imsize_t n); 16 template <class CharT, class Predicate, class Allocator > 17 explicit bitset(const string <CharT, Predicate, Allocator >&); 18 bitset() {} 19 0 // 1 bitset operator () const; // 3 bitset& operator=(const bitset&); 4 bitset& operator&=(const bitset&); 5 bitset& operator =(const bitset&); 6 bitset& operatorˆ=(const bitset&); 7 bitset& operator <<=(imsize_t); 8 bitset& operator >>=(imsize_t); 9 // 30 bool operator==(const bitset&) const; 31 bool operator!=(const bitset&) const; 3 33 constexpr imsize_t size() const noexcept; 34 // 35 unsigned char byte(imsize_t) const; 36 // 37 bool bit(imsize_t) const; 38 bool operator[]( imsize_t) const; // 41 bitset& reset(); 4 // 43 bitset& set(); 44 bitset& set(imsize_t, bool flag); 45 // 46 bitset& flip(); 47 // ( ) 48 bitset& flip(imsize_t pos); 49 // 50 imsize_t to_uint() const; 51 unsigned long to_ulong() const; 5 // 53 template <class CharT, class Predicate = type_comparison <CharT >, class Allocator = allocator <CharT,

4 1 array_iterator <CharT >>> 54 string <CharT, Predicate, Allocator > to_string() const; 55 //1 56 imsize_t count() const; 57 }; 58 } string string 1. 3 template <imsize_t N> 4 class bitset { 5 // N 0 6 bitset& byte_check() { 7 //8 8 if ((N & 7)!= 0) x[array_size - 1] &= (1 << (N & 7)) - 1; 9 return *this; 10 } 11 }; 1 } bitset& 3 template <imsize_t N> 4 class bitset { 5 public: 6 // 7 unsigned char byte(imsize_t n) const { return x[n]; } 8 // 9 bool operator[]( imsize_t pos) const { return (x[pos >> 3] & (1 << (pos & 7))) > 0; } 10 bool bit(imsize_t pos) const { return (x[pos >> 3] & (1 << (pos & 7))) > 0; } 11 }; 1 } true or false and 3 template <imsize_t N> 4 class bitset { 5 public: 6 constexpr bitset() :x{} {} 7 bitset(const bitset& b) { 8 for (imsize_t i = 0; i < array_size; ++i) this ->x[i] = b.x[i]; 9 } 10 template <imsize_t N> 11 bitset(const bitset <N>& b) : x{} { 1 for (imsize_t i = 0, n = (min)(this ->array_size, b.array_size); i < n; ++i) this ->x[i] = b.x[i]; 13 } 14 bitset(imsize_t n) :x{} { 15 // 16 switch (array_size) { 17 case 1: 18 x[0] = static_cast <unsigned char >(n & 0xFF); 19 break; 0 case : 1 x[0] = static_cast <unsigned char >(n & 0xFF);

5 1 3 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 3 break; 4 case 3: 5 x[0] = static_cast <unsigned char >(n & 0xFF); 6 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 7 x[] = static_cast <unsigned char >((n & (0xFF << 16)) >> 16); 8 break; 9 //64 b i t 30 #if defined _IMATH_INT_64BIT_ 31 case 4: 3 x[0] = static_cast <unsigned char >(n & 0xFF); 33 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 34 x[] = static_cast <unsigned char >((n & (0xFF << 16)) >> 16); 35 x[3] = static_cast <unsigned char >((n & (0xFF << 4)) >> 4); 36 break; 37 case 5: 38 x[0] = static_cast <unsigned char >(n & 0xFF); 39 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 40 x[] = static_cast <unsigned char >((n & (0xFF << 16)) >> 16); 41 x[3] = static_cast <unsigned char >((n & (0xFF << 4)) >> 4); 4 x[4] = static_cast <unsigned char >((n & (0xFF << 3)) >> 3); 43 break; 44 case 6: 45 x[0] = static_cast <unsigned char >(n & 0xFF); 46 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 47 x[] = static_cast <unsigned char >((n & (0xFF << 16)) >> 16); 48 x[3] = static_cast <unsigned char >((n & (0xFF << 4)) >> 4); 49 x[4] = static_cast <unsigned char >((n & (0xFF << 3)) >> 3); 50 x[5] = static_cast <unsigned char >((n & (0xFF << 40)) >> 40); 51 break; 5 case 7: 53 x[0] = static_cast <unsigned char >(n & 0xFF); 54 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 55 x[] = static_cast <unsigned char >((n & (0xFF << 16)) >> 16); 56 x[3] = static_cast <unsigned char >((n & (0xFF << 4)) >> 4); 57 x[4] = static_cast <unsigned char >((n & (0xFF << 3)) >> 3); 58 x[5] = static_cast <unsigned char >((n & (0xFF << 40)) >> 40); 59 x[6] = static_cast <unsigned char >((n & (0xFF << 48)) >> 48); 60 break; 61 #endif 6 default: 63 x[0] = static_cast <unsigned char >(n & 0xFF); 64 x[1] = static_cast <unsigned char >((n & (0xFF << 8)) >> 8); 65 x[] = static_cast <unsigned char >((n & (0xFF << 16)) >> 16); 66 x[3] = static_cast <unsigned char >((n & (0xFF << 4)) >> 4); 67 #if defined _IMATH_INT_64BIT_ 68 x[4] = static_cast <unsigned char >((n & (0xFF << 3)) >> 3); 69 x[5] = static_cast <unsigned char >((n & (0xFF << 40)) >> 40); 70 x[6] = static_cast <unsigned char >((n & (0xFF << 48)) >> 48); 71 x[7] = static_cast <unsigned char >((n & (0xFF << 56)) >> 56); 7 #endif 73 } 74 byte_check(); 75 } 76 template <class CharT, class Predicate, class Allocator > 77 explicit bitset(const string <CharT, Predicate, Allocator >& str) { 78 for (imsize_t i = 0; i < array_size; ++i) { 79 for (imsize_t j = 0; j < 8; ++j) { 80 if (str.size() - - ((i << 3) + j) < 0) x[i] &= ((1 << j) - 1); 81 else if (str[str.size() - - ((i << 3) + j)] == 1 ) x[i] = (1 << j); 8 else if (str[str.size() - - ((i << 3) + j)] == 0 ) x[i] &= (1 << j); 83 } 84 } 85 byte_check(); 86 } 87 bitset() {} // 90 bitset operator () const { 91 bitset <N> temp; 9 for (imsize_t i = 0; i < array_size; ++i) temp.x[i] = this ->x[i]; 93 return temp.byte_check(); 94 } 95 // 96 bitset& operator=(const bitset& b) { 97 for (imsize_t i = 0; i < array_size; ++i) this ->x[i] = b.x[i]; 98 } 99 bitset& operator&=(const bitset& b) { 100 for (imsize_t i = 0; i < array_size; ++i) this ->x[i] &= b.x[i]; 101 } 10 bitset& operator =(const bitset& b) { 103 for (imsize_t i = 0; i < array_size; ++i) this ->x[i] = b.x[i]; 104 } 105 bitset& operatorˆ=(const bitset& b) { 106 for (imsize_t i = 0; i < array_size; ++i) this ->x[i] ˆ= b.x[i]; 107 } 108 // 109 bool operator==(const bitset& b) const { 110 for (imsize_t i = 0; i < array_size; ++i) if (this ->x[i]!= b.x[i]) return false;

6 return true; 11 } 113 bool operator!=(const bitset& b) const { 114 return (*this == b); 115 } constexpr imsize_t size() const noexcept { return N; } 118 // 119 unsigned char byte(imsize_t n) const { return x[n]; } // 1 bitset& reset() { 13 for (imsize_t i = 0; i < array_size; ++i) x[i] = 0; 14 return *this; 15 } 16 // 17 bitset& set() { 18 for (imsize_t i = 0; i < array_size; ++i) x[i] = 0xFF; 19 return byte_check(); 130 } 131 bitset& set(imsize_t pos, bool flag = true) { 13 if (pos >= N) return *this; 133 if(flag) x[pos >> 3] = (1 << (pos & 7)); 134 else x[pos >> 3] &= (1 << (pos & 7)); 135 return *this; 136 } 137 // 138 bitset& flip() { 139 for (imsize_t i = 0; i < array_size; ++i) this ->x[i] = this ->x[i]; 140 return byte_check(); 141 } 14 // 143 bitset& flip(imsize_t pos) { 144 if (pos >= N) return *this; 145 x[pos >> 3] ˆ= (1 << (pos & 7)); 146 return *this; 147 } // 150 imsize_t to_uint() const { 151 imsize_t result = 0; 15 for (imsize_t i = 0, n = (min<imsize_t >)(4, array_size); i < n; ++i) result = x[i] << (8 * i); 153 return result; 154 } 155 // 156 unsigned long to_ulong() const { 157 imsize_t result = 0; 158 for (imsize_t i = 0, n = (min<imsize_t >)(8, array_size); i < n; ++i) result = x[i] << (8 * i); 159 return result; 160 } 161 // 16 template <class CharT, class Predicate = type_comparison <CharT >, class Allocator = allocator <CharT, array_iterator <CharT >>> 163 string <CharT, Predicate, Allocator > to_string() const { 164 string <CharT, Predicate, Allocator > result; 165 result.reserve(n + 1); 166 // N 167 { 168 unsigned char temp = x[array_size - 1]; 169 // N if ((N & 7)!= 0) { 171 for (imsize_t j = 9 - (N & 7); j <= 8; ++j) 17 result.push_back(((temp & (1 << (8 - j))) > 0)? 1 : 0 ); 173 } 174 else { 175 for (imsize_t j = 1; j <= 8; ++j) 176 result.push_back(((temp & (1 << (8 - j))) > 0)? 1 : 0 ); 177 } 178 } 179 for (imsize_t i = ; i <= array_size; ++i) { 180 unsigned char temp = x[array_size - i]; 181 for (imsize_t j = 1; j <= 8; ++j) 18 result.push_back(((temp & (1 << (8 - j))) > 0)? 1 : 0 ); 183 } 184 return result; 185 } 186 //1 187 imsize_t count() const { 188 imsize_t result = 0; 189 for (imsize_t i = 0; i < array_size; ++i) { 190 unsigned char temp = x[i]; 191 for (imsize_t j = 0; j < 8; ++j) 19 result += (temp & (1 << j)) > 0; 193 } 194 return result; 195 } 196 }; 197 }

7 1 5 n n >> 3 1 n& n>>3 n& n& (n>>3+1) n& n>> n>> template <imsize_t N> 4 class bitset { 5 public: 6 bitset& operator <<=(imsize_t pos) { 7 imsize_t surplus = pos & 7; // 8 imsize_t shift = pos >> 3; // 9 // s u r p l u s 10 for (imsize_t i = 1; i <= array_size; ++i) { 11 x[array_size - i] <<= surplus; 1 // 13 if (array_size!= i) x[array_size - i] = (x[array_size i] >> (8 - surplus)); 14 } 15 // s h i f t 16 for (imsize_t i = 1; array_size >= i + shift; ++i) x[array_size - i] = x[array_size - i - shift]; 17 //0 18 for (imsize_t i = 0; i < shift; ++i) x[i] = 0; 19 return byte_check(); 0 } 1 }; } 3 template <imsize_t N> 4 class bitset { 5 public: 6 bitset& operator >>=(imsize_t pos) { 7 imsize_t surplus = pos & 7; // 8 imsize_t shift = pos >> 3; // 9 // s u r p l u s 10 for (imsize_t i = 0; i < array_size; ++i) { 11 x[i] >>= surplus; 1 // 13 if (i + 1!= array_size) x[i] = (x[i + 1] << (8 - surplus)); 14 } 15 // s h i f t 16 for (imsize_t i = 0; i + shift < array_size; ++i) x[i] = x[i + shift]; 17 // 18 for (imsize_t i = 1; i <= shift; ++i) x[array_size - i] = 0; 19 return *this; 0 } 1 }; } 3 // 4 template <imsize_t N> 5 inline bitset <N> operator&(const bitset <N>& b1, const bitset <N>& b) {

8 1 6 6 bitset <N> temp(b1); 7 return temp &= b; 8 } 9 template <imsize_t N> 10 inline bitset <N> operator (const bitset <N>& b1, const bitset <N>& b) { 11 bitset <N> temp(b1); 1 return temp = b; 13 } 14 template <imsize_t N> 15 inline bitset <N> operatorˆ(const bitset <N>& b1, const bitset <N>& b) { 16 bitset <N> temp(b1); 17 return temp ˆ= b; 18 } 19 template <imsize_t N> 0 inline bitset <N> operator <<(const bitset <N>& b, imsize_t n) { 1 bitset <N> temp(b); return temp <<= n; 3 } 4 template <imsize_t N> 5 inline bitset <N> operator >>(const bitset <N>& b, imsize_t n) { 6 bitset <N> temp(b); 7 return temp >>= n; 8 } 9 }

9 //1 4 struct full_adder { 5 bool c0; // 6 bool s; // 7 8 constexpr full_adder() : c0(false), s(false) {} 9 //c: 10 constexpr full_adder(bool a, bool b, bool c) : c0(a&c b & c a & b), s(aˆbˆc) {} 11 1 void operator()(bool a, bool b, bool c) { c0 = a & c b & c a & b; s = a ˆ b ˆ c; } 13 }; 14 } n 3 // n 4 template <imsize_t N> 5 struct n_full_adder { 6 bool c0; // 7 bitset <N> s; // 8 9 constexpr n_full_adder() : c0(false) {} 10 //c: 11 n_full_adder(const bitset <N>& a, const bitset <N>& b) { 1 bool c = false; // 13 // 14 for (imsize_t i = 0; i < N; ++i) { 15 full_adder temp(a[i], b[i], c); 16 s.set(i, temp.s); 17 c = temp.c0; 18 } 19 c0 = c; 0 } 1 void operator()(const bitset <N>& a, const bitset <N>& b) { 3 bool c = false; // 4 // 5 for (imsize_t i = 0; i < N; ++i) { 6 full_adder temp(a[i], b[i], c); 7 s.set(i, temp.s); 8 c = temp.c0; 9 } 30 c0 = c; 31 } 3 }; 33 }

10 8 1 int main() { 3 iml::bitset <0> a(13), b(456); 4 // u i n t 5 std::cout << iml::n_full_adder <0>(bit_a, bit_b).s.to_uint() << std::endl; 6 7 return 0; 8 } 1 3 //1 4 struct half_adder { 5 bool c; // 6 bool s; // 7 8 constexpr half_adder() : c(false), s(false) {} 9 constexpr half_adder(bool a, bool b) : c(a&b), s(aˆb) {} void operator()(bool a, bool b) { c = a & b; s = a ˆ b; } 1 }; // ( 1 ) 15 template <imsize_t N> 16 bitset <N> twos_complement(const bitset <N>& b) { 17 bitset <N> temp1( b); 18 half_adder temp; 19 temp.c = true; 0 for (imsize_t i = 0; (i < N) && temp.c; ++i) { 1 temp(temp1[i], temp.c); temp1.set(i, temp.s); 3 } 4 if (temp.c) temp1.set(n - 1, temp.c); 5 6 return temp1; 7 } 8 } 3 // n 4 template <imsize_t N> 5 struct n_subtractor { 6 bool c0; // ( ) 7 bitset <N> s; // 8 9 constexpr n_subtractor() : c0(false) {} 10 //c: 11 n_subtractor(const bitset <N>& a, const bitset <N>& b) { 1 bool c =true; // 13 // 14 for (imsize_t i = 0; i < N; ++i) { 15 full_adder temp(a[i],!b[i], c); 16 s.set(i, temp.s); 17 c = temp.c0; 18 } 19 c0 = c; 0 } 1 void operator()(const bitset <N>& a, const bitset <N>& b) { 3 bool c = true; // 4 // 5 for (imsize_t i = 0; i < N; ++i) { 6 full_adder temp(a[i],!b[i], c); 7 s.set(i, temp.s); 8 c = temp.c0; 9 } 30 c0 = c; 31 } 3 }; 33 }

11 9 c0 true 1 int main() { 3 iml::bitset <0> a(13), b(456); 4 // u i n t 5 iml::n_subtractor <0> result(a, b); 6 if (result.c0) std::cout << result.s.to_uint() << std::endl; 7 else std::cout << - << iml:: twos_complement(result.s).to_uint() << std::endl;; 8 9 return 0; 10 }. H SR-FF L Not 3 // HL SR -FF(true:H,false:L) 4 template <bool HL> 5 struct SR_FF { 6 bool q, nq; // 7 8 constexpr SR_FF() : q(false), nq(true) {} 9 SR_FF(bool ini_q, bool s, bool r, bool clock) : q(ini_q), nq(!ini_q) { 10 // n o t 11 clock = (HL)? clock :!clock; 1 bool ns =!(s & clock), nr =!(r & clock); 13 // 14 q =!(ns & nq); 15 nq =!(nr & q); 16 q =!(ns & nq); 17 nq =!(nr & q); 18 } 19 0 void operator()(bool s, bool r, bool clock) { 1 // n o t clock = (HL)? clock :!clock; 3 bool ns =!(s & clock), nr =!(r & clock); 4 // 5 q =!(ns & nq); 6 nq =!(nr & q); 7 q =!(ns & nq); 8 nq =!(nr & q); 9 } 30 }; 31 } D-FF JK-FF T-FF

12 10 3 // H L D -FF(true:H,false:L) 4 template <bool HL> 5 struct D_FF { 6 bool q, nq; // 7 8 constexpr D_FF() : q(false), nq(true) {} 9 D_FF(bool ini_q, bool d, bool clock) : q(ini_q), nq(!ini_q) { 10 // n o t 11 clock = (HL)? clock :!clock; 1 bool ns =!(d & clock), nr =!(!d & clock); 13 // 14 q =!(ns & nq); 15 nq =!(nr & q); 16 q =!(ns & nq); 17 nq =!(nr & q); 18 } 19 0 void operator()(bool d, bool clock) { 1 // n o t clock = (HL)? clock :!clock; 3 bool ns =!(d & clock), nr =!(!d & clock); 4 // 5 q =!(ns & nq); 6 nq =!(nr & q); 7 q =!(ns & nq); 8 nq =!(nr & q); 9 } // clear 3 void clear() { q = false; nq = true; } 33 }; // HL JK -FF(true:H,false:L) 36 template <bool HL> 37 struct JK_FF { 38 bool q, nq; // constexpr JK_FF() : q(false), nq(true) {} 41 JK_FF(bool ini_q, bool j, bool k, bool clock) : q(ini_q), nq(!ini_q) { 4 // n o t 43 clock = (HL)? clock :!clock; 44 bool ns =!(j & clock & nq), nr =!(k & clock & q); 45 // 46 q =!(ns & nq); 47 nq =!(nr & q); 48 q =!(ns & nq); 49 nq =!(nr & q); 50 } 51 5 void operator()(bool j, bool k, bool clock) { 53 // n o t 54 clock = (HL)? clock :!clock; 55 bool ns =!(j & clock & nq), nr =!(k & clock & q); 56 // 57 q =!(ns & nq); 58 nq =!(nr & q); 59 q =!(ns & nq); 60 nq =!(nr & q); 61 } 6 63 // clear 64 void clear() { q = false; nq = true; } 65 }; // H L T -FF(true:H,false:L) 68 template <bool HL> 69 struct T_FF { 70 bool q, nq; // 71 7 constexpr T_FF() : q(false), nq(true) {} 73 T_FF(bool ini_q, bool t, bool clock) : q(ini_q), nq(!ini_q) { 74 // n o t 75 clock = (HL)? clock :!clock; 76 bool ns =!(t & clock), nr =!(t & clock); 77 // 78 q =!(ns & nq); 79 nq =!(nr & q); 80 q =!(ns & nq); 81 nq =!(nr & q); 8 } void operator()(bool t, bool clock) { 85 // n o t 86 clock = (HL)? clock :!clock; 87 bool ns =!(t & clock & nq), nr =!(t & clock & q); 88 // 89 q =!(ns & nq); 90 nq =!(nr & q);

13 11 91 q =!(ns & nq); 9 nq =!(nr & q); 93 } // clear 96 void clear() { q = false; nq = true; } 97 }; 98 } 1 D-FF 3 // n 4 template <imsize_t N> 5 struct shift_register { 6 bitset <N> x; // 7 D_FF <true > dff[n]; shift_register(const bitset <N>& b) : x(b) {} 11 // (b: ) 1 void operator()(bool clock, bool b = false) { 13 dff[0](b, clock); 14 for (imsize_t i = 1; i < N; ++i) { 15 dff[i](x[i - 1], clock); 16 x.set(i - 1, dff[i - 1].q); 17 } 18 x.set(n - 1, dff[n - 1].q); 19 } 0 }; 1 } 1 int main() { 3 iml::shift_register <8> shift(iml::bitset <8>(iml::string <char >(" "))); 4 5 for (size_t i = 0; i < 8; ++i) { 6 std::cout << i << : << shift.x.to_string <char >(). c_str() << std::endl; 7 shift(true); 8 } 9 10 return 0; 11 }

解きながら学ぶ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

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

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

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

新版明解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

8 if switch for while do while 2

8 if switch for while do while 2 (Basic Theory of Information Processing) ( ) if for while break continue 1 8 if switch for while do while 2 8.1 if (p.52) 8.1.1 if 1 if ( ) 2; 3 1 true 2 3 false 2 3 3 8.1.2 if-else (p.54) if ( ) 1; else

More information

Java updated

Java updated Java 2003.07.14 updated 3 1 Java 5 1.1 Java................................. 5 1.2 Java..................................... 5 1.3 Java................................ 6 1.3.1 Java.......................

More information

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

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

やさしい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

For_Beginners_CAPL.indd

For_Beginners_CAPL.indd CAPL Vector Japan Co., Ltd. 目次 1 CAPL 03 2 CAPL 03 3 CAPL 03 4 CAPL 04 4.1 CAPL 4.2 CAPL 4.3 07 5 CAPL 08 5.1 CANoe 5.2 CANalyzer 6 CAPL 10 7 CAPL 11 7.1 CAPL 7.2 CAPL 7.3 CAPL 7.4 CAPL 16 7.5 18 8 CAPL

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

cpp4.dvi

cpp4.dvi 2017 c 4 C++ (4) C++, 41, 42, 1, 43,, 44 45, 41 (inheritance),, C++,, 100, 50, PCMCIA,,,,,,,,, 42 1 421 ( ), car 1 [List 41] 1: class car { 2: private: 3: std::string m model; // 4: std::string m maker;

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入門 537,... 224,... 224,... 32, 35,... 188, 216, 312 -... 38 -... 38 --... 102 --... 103 -=... 111 -classpath... 379 '... 106, 474!... 57, 97!=... 56 "... 14, 476 %... 38 %=... 111 &... 240, 247 &&... 66,

More information

解きながら学ぶJava入門編

解きながら学ぶJava入門編 44 // class Negative { System.out.print(""); int n = stdin.nextint(); if (n < 0) System.out.println(""); -10 Ÿ 35 Ÿ 0 n if statement if ( ) if i f ( ) if n < 0 < true false true false boolean literalboolean

More information

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1 Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の までを処理し どれにも一致しない場合 default; から直後の までを処理する 但し 式や値 1 値 2は整数または文字である switch( 式 ) case 値 1: // コロン : です セミコロン ; と間違えないように!!

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

haskell.gby

haskell.gby Haskell 1 2 3 Haskell ( ) 4 Haskell Lisper 5 Haskell = Haskell 6 Haskell Haskell... 7 qsort [8,2,5,1] [1,2,5,8] "Hello, " ++ "world!" "Hello, world!" 1 + 2 div 8 2 (+) 1 2 8 div 2 3 4 map even [1,2,3,4]

More information

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225 Java Java Java Java Java 4 p35 4-2 * *** ***** *** * Unix p36 4-3 a,b,c,d 100,200,250,500 a*b = 20000 a*b+c = 20250 a*b+c*d = 145000 (a+b)*(c+d) = 225000 a+b*c+d = 50600 b/a+d/c = 4 p38 4-4 (1) mul = 1

More information

‚æ4›ñ

‚æ4›ñ ( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9

More information

2017_08_ICN研究会_印刷用

2017_08_ICN研究会_印刷用 class Producer : noncopyable public: run() m_face.setinterestfilter("/example/testapp", bind(&producer::oninterest, this, _1, _2), RegisterPrefixSuccessCallback(), bind(&producer::onregisterfailed, this,

More information

untitled

untitled Verilog HDL Verilog HDL VerilogHDL veriloghdl / CPLD , 1bit 2 MUX 5 D,E) always) module MUX(out, a, b, sel); output out; input a, b, sel; A) IF module MUX(out, a, b, sel); output out; input a, b, sel;

More information

1 1 2 2 2-1 2 2-2 4 2-3 11 2-4 12 2-5 14 3 16 3-1 16 3-2 18 3-3 22 4 35 4-1 VHDL 35 4-2 VHDL 37 4-3 VHDL 37 4-3-1 37 4-3-2 42 i

1 1 2 2 2-1 2 2-2 4 2-3 11 2-4 12 2-5 14 3 16 3-1 16 3-2 18 3-3 22 4 35 4-1 VHDL 35 4-2 VHDL 37 4-3 VHDL 37 4-3-1 37 4-3-2 42 i 1030195 15 2 10 1 1 2 2 2-1 2 2-2 4 2-3 11 2-4 12 2-5 14 3 16 3-1 16 3-2 18 3-3 22 4 35 4-1 VHDL 35 4-2 VHDL 37 4-3 VHDL 37 4-3-1 37 4-3-2 42 i 4-3-3 47 5 52 53 54 55 ii 1 VHDL IC VHDL 5 2 3 IC 4 5 1 2

More information

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

アルゴリズムとデータ構造1 1 200972 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi ://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2009/index.html 29 20 32 14 24 30 48 7 19 21 31 Object public class

More information

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

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 C++ 1 C C++ C++ C C C++ 1.1 C printf() scanf() C++ C 1-1 #include int a; scanf( "%d", &a ); printf( "a = %d\n", a ); C++ 1-2 int a; std::cin >> a; std::cout

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

1.ppt

1.ppt /* * Program name: hello.c */ #include int main() { printf( hello, world\n ); return 0; /* * Program name: Hello.java */ import java.io.*; class Hello { public static void main(string[] arg)

More information

An Introduction to OSL

An Introduction to OSL .... An Introduction to OSL TeamGPS 2009 3 CSA (TeamGPS) An Introduction to OSL 2009 3 CSA 1 / 45 ..1..2..3..4.... : (TeamGPS) An Introduction to OSL 2009 3 CSA 2 / 45 Disclaimer: OSL Bonanza Crafty (pruning/cut,

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double

More information

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致致しない場合 default: から直後の まで処理します 式の結果 ラベル 定数 整数または文字 (byte, short, int,

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

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

ohp02.dvi

ohp02.dvi 172 2017.7.16 1 ? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X 2 ( ) 3 2-0 ( ) ( ) ( ) (12) ( ) (112) 31) 281 26 1 4 (syntax) (semantics) ( ) 5 BNF BNF(Backus Normal Form) Joun Backus (grammer) English grammer

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

Copyright c 2008 Zhenjiang Hu, All Right Reserved.

Copyright c 2008 Zhenjiang Hu, All Right Reserved. 2008 10 27 Copyright c 2008 Zhenjiang Hu, All Right Reserved. (Bool) True False data Bool = False True Remark: not :: Bool Bool not False = True not True = False (Pattern matching) (Rewriting rules) not

More information

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

アルゴリズムとデータ構造1 1 2005 7 22 22 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) 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

ALG ppt

ALG ppt 2012614 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 2 2 3 29 20 32 14 24 30 48 7 19 21 31 4 N O(log N) 29 O(N) 20 32 14 24 30 48 7 19 21 31 5

More information

C# ++ MASA C# ( ) XNA 1.1 C# ( ) VisualStuio XNA 4.0 VisualStuio XNA 3.1 * * *3 2.1 VisualStuio Windows ( TextGam

C# ++ MASA C# ( ) XNA 1.1 C# ( ) VisualStuio XNA 4.0 VisualStuio XNA 3.1 * * *3 2.1 VisualStuio Windows ( TextGam C# ++ MASA 2011 8 1 C# ( ) XNA 1.1 C# ( ) VisualStuio 2010 + XNA 4.0 VisualStuio 2008 + XNA 3.1 *1 1.2 1 *2 1.3 2 *3 2.1 VisualStuio Windows ( TextGame2 ) OK *1 XNA 3.1 4.0 *2 *3 1 TextGame2 ( Ship ) 32*32

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 tutimura@mist.i.u-tokyo.ac.jp kaneko@ipl.t.u-tokyo.ac.jp 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

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

明解Javaによるアルゴリズムとデータ構造 21 algorithm List 1-1 a, b, c max Scanner Column 1-1 List 1-1 // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); Chap01/Max3.java

More information

cpp2.dvi

cpp2.dvi 2018 c 2 C++ (2) STL, C++ 21 string 22 STL 23 21 string C, \0, (, ), (, ), /,,,, C++,,, string string,,,,,, include,,, int, > >>,,,, getline(, string ), [List 21] 2: #include 3: 4:

More information

exec.dvi

exec.dvi 2018 c 6, Mini-C C++ 6211 611, 61, print,,, (run ),,, (int ), 7, x, x "a" 3 "b" 4 "x" 10 (, ), x STL map 1 + 2, 1 2,, x = ;, 1, 2 x { 1 ; 2 ; ; m, if ( ) { 1 else { 2, 1,, 2 0, 1, 3 0, 2,,, main 6 1 ,,

More information

とても使いやすい Boost の serialization

とても使いやすい Boost の serialization とても使いやすい Boost の serialization Zegrahm シリアライズ ( 直列化 ) シリアライズ ( 直列化 ) とは何か? オブジェクトデータをバイト列や XML フォーマットに変換すること もう少しわかりやすく表現すると オブジェクトの状態を表す変数 ( フィールド ) とオブジェクトの種類を表す何らかの識別子をファイル化出来るようなバイト列 XML フォーマット形式で書き出す事を言う

More information

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致しない場合 default: から直後の まで処理します 式は byte, short, int, char 型 ( 文字または整数 ) を演算結果としますラベルには整数リテラル

More information

fp.gby

fp.gby 1 1 2 2 3 2 4 5 6 7 8 9 10 11 Haskell 12 13 Haskell 14 15 ( ) 16 ) 30 17 static 18 (IORef) 19 20 OK NG 21 Haskell (+) :: Num a => a -> a -> a sort :: Ord a => [a] -> [a] delete :: Eq a => a -> [a] -> [a]

More information

A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3,

A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 40 2 1. 2 2. 52 3. A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 4. 13 5. 6. 7. 8. 9. 13 10. 11. 12. 1 VC++ VC++ Visual C++ Professional 2010 Visual C++ 2010 express Windows whist 2 OK] 3 Form1 size 800, 500

More information

VB.NETコーディング標準

VB.NETコーディング標準 (C) Copyright 2002 Java ( ) VB.NET C# AS-IS extremeprogramming-jp@objectclub.esm.co.jp bata@gold.ocn.ne.jp Copyright (c) 2000,2001 Eiwa System Management, Inc. Object Club Kenji Hiranabe02/09/26 Copyright

More information

J.JSSAC Vol. 7, No. 2, Mathematica Maple,., Open asir Open xxx asir. Open xxx Open asir, asir., Open xxx, Linux Open asir Open sm1 (kan/sm1). C

J.JSSAC Vol. 7, No. 2, Mathematica Maple,., Open asir Open xxx asir. Open xxx Open asir, asir., Open xxx, Linux Open asir Open sm1 (kan/sm1). C J.JSSAC (1999) Vol. 7, No. 2, pp. 2-17 Open asir HPC (Received 1997/12/1) 1 Open asir Open xxx,., ( ),,,,,.,., (1) (2) (3) (4),. Open xxx,.,., 1.,.,., 0 10, dx,.,., ohara@math.kobe-u.ac.jp taka@math.kobe-u.ac.jp

More information

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

8 / 0 1 i++ i 1 i-- i C !!! C 2 C 2006 5 2 printf() 1 [1] 5 8 C 5 ( ) 6 (auto) (static) 7 (=) 1 8 / 0 1 i++ i 1 i-- i 1 2 2.1 C 4 5 3 13!!! C 2 2.2 C ( ) 4 1 HTML はじめ mkdir work 作業用ディレクトリーの作成 emacs hoge.c& エディターによりソースプログラム作成 gcc -o fuga

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

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

Microsoft PowerPoint - CproNt02.ppt [互換モード] 第 2 章 C プログラムの書き方 CPro:02-01 概要 C プログラムの構成要素は関数 ( プログラム = 関数の集まり ) 関数は, ヘッダと本体からなる 使用する関数は, プログラムの先頭 ( 厳密には, 使用場所より前 ) で型宣言 ( プロトタイプ宣言 ) する 関数は仮引数を用いることができる ( なくてもよい ) 関数には戻り値がある ( なくてもよい void 型 ) コメント

More information

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

Microsoft Word - C.....u.K...doc C uwêííôöðöõ Ð C ÔÖÐÖÕ ÐÊÉÌÊ C ÔÖÐÖÕÊ C ÔÖÐÖÕÊ Ç Ê Æ ~ if eíè ~ for ÒÑÒ ÌÆÊÉÉÊ ~ switch ÉeÍÈ ~ while ÒÑÒ ÊÍÍÔÖÐÖÕÊ ~ 1 C ÔÖÐÖÕ ÐÊÉÌÊ uê~ ÏÒÏÑ Ð ÓÏÖ CUI Ô ÑÊ ÏÒÏÑ ÔÖÐÖÕÎ d ÈÍÉÇÊ ÆÒ Ö ÒÐÑÒ ÊÔÎÏÖÎ d ÉÇÍÊ

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

Java講座

Java講座 ~ 第 1 回 ~ 情報科学部コンピュータ科学科 2 年竹中優 プログラムを書く上で Hello world 基礎事項 演算子 構文 2 コメントアウト (//, /* */, /** */) をしよう! インデントをしよう! 変数などにはわかりやすい名前をつけよう! 要するに 他人が見て理解しやすいコードを書こうということです 3 1. Eclipse を起動 2. ファイル 新規 javaプロジェクト

More information

tuat1.dvi

tuat1.dvi ( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )

More information

bitvisor-ipc v12b.key

bitvisor-ipc v12b.key PC PC OS PC PC 1 1 2 101 101 enum tre_rpc_direction { TRE_RPC_DIRECTION_REQUEST, TRE_RPC_DIRECTION_RESULT }; struct tre_rpc_request { }; enum tre_rpc_direction direction; ulong id; ulong proc_number;

More information

2008chom.pdf

2008chom.pdf CHomP Pawe l Pilarczyk 1 CHomP Computational Homology Project [3] OS Windows Mac Unix Linux [3] CHomP [3] 2 3 CHomP CHomP 4 5 C++ [1] 2 CHomP 1 2 K 1 = { A 1 A 2 A 3, A 1 A 2, A 2 A 3, A 1 A 3, A 3 A 4,

More information

ALG ppt

ALG ppt 2012 6 21 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 l l O(1) l l l 2 (123 ) l l l l () l H(k) = k mod n (k:, n: ) l l 3 4 public class MyHashtable

More information

: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 2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または

More information

untitled

untitled 2011 6 20 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2011/index.html tech.ac.jp/k1sakai/lecture/alg/2011/index.html html 1 O(1) O(1) 2 (123) () H(k) = k mod n

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

untitled

untitled II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}

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

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

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

C++11概要 ライブラリ編

C++11概要 ライブラリ編 C++11 概要ライブラリ編 H.24/05/26 Egtra Boost. 勉強会 #9 つくば 注意 網羅はしていません 規格を (N3337.pdf も可 ) を読む cpprefjp を書く 読む Misc スマートポインタ unique_ptr 以下の上位互換 std::auto_ptr boost::scoped_ptr, boost::scoped_array shared_ptr boost::shared_ptr

More information

パターン化されたロジックのコンポーネント化

パターン化されたロジックのコンポーネント化 UI C++Builder SEAXER 2 CAD BASIC CISC/RISC C++ Perl Java 3 PM 4 T^T) 5 UNIX 6 7 8 true/false SetLastError(); throw() BOOL abort 9 UML PM OOPS esign attern C/C++ 10 Don t Repeat Yourself 11 Windows3.1 12

More information

関数のコメントが細かく多い クラスや 関数 1つ 1 つにコメントを細かく多く入れる事を正しいと勘違いしている人は多くいます また 学校によってはその様な指導をする所もあります しかし プログラムが分かり易ければコメントを書く必要性は低く 多いと逆に読みにくくなります 特に関数の説明をするコメントの

関数のコメントが細かく多い クラスや 関数 1つ 1 つにコメントを細かく多く入れる事を正しいと勘違いしている人は多くいます また 学校によってはその様な指導をする所もあります しかし プログラムが分かり易ければコメントを書く必要性は低く 多いと逆に読みにくくなります 特に関数の説明をするコメントの 悪いプログラムの書き方 今回は応募作品中に見られる 初心者にありがちな悪いプログラムの書き方について 例をあげて説明したいと思います 悪い書き方これだけではなく まだ沢山ありますので更に本を読んだりして勉強して下さい また 書き方について更に学びたい場合は コーディングルール をみてみると良いでしょう 会社やチームごとに細かな違いがありますが コーディングルール はどの様にすれば間違いが少なく 無駄が少なく

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double

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

ohp08.dvi

ohp08.dvi 19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data

More information

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

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 1. 1.1. 1.2. 1 PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 2. 2.1. 2 1 2 C a b N: PC BC c 3C ac b 3 4 a F7 b Y c 6 5 a ctrl+f5) 4 2.2. main 2.3. main 2.4. 3 4 5 6 7 printf printf

More information

2: 3: A, f, φ f(t = A sin(2πft + φ = A sin(ωt + φ ω 2πf 440Hz A ( ( 4 ( 5 f(t = sin(2πf 1t + sin(2πf 2 t = 2 sin(2πt(f 1 + f 2 /2 cos(2πt(f 1 f

2: 3: A, f, φ f(t = A sin(2πft + φ = A sin(ωt + φ ω 2πf 440Hz A ( ( 4 ( 5 f(t = sin(2πf 1t + sin(2πf 2 t = 2 sin(2πt(f 1 + f 2 /2 cos(2πt(f 1 f 12 ( TV TV, CATV, CS CD, DAT, DV, DVD ( 12.1 12.1.1 1 1: T (sec f (Hz T= 1 f P a = N/m 2 1.013 10 5 P a 1 10 5 1.00001 0.99999 2,3 1 2: 3: 12.1.2 A, f, φ f(t = A sin(2πft + φ = A sin(ωt + φ ω 2πf 440Hz

More information

ex12.dvi

ex12.dvi 1 0. C, char., char, 0,. C, ("),., char str[]="abc" ; str abc.,, str 4. str 3. char str[10]="abc" ;, str 10, str 3., char s[]="abc", t[10] ;, t = s. ASCII, 0x00 0x7F, char., "abc" 3, 1. 1 8 256, 2., 2

More information

mbed_library_study_meeting_v1.0.key

mbed_library_study_meeting_v1.0.key mbed _mbed 2014 11 7 https://atnd.org/events/57766 version 1.0, 07-Nov.-2014 Tedd OKANO mbed - - 4.0 (^^; 1 mbed TEDD OKANO https://twitter.com/tedd_okano 10 I 2 C http://developer.mbed.org/users/okano/

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

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲 Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲を決定します 次の型が利用でき これらの型は特に基本型とよばれます 基本型 値の種類 値の範囲 boolean

More information

226

226 226 227 Main ClientThread Request Channel WorkerThread Channel startworkers takerequest requestqueue threadpool WorkerThread channel run Request tostring execute name number ClientThread channel random

More information

問題1 以下に示すプログラムは、次の処理をするプログラムである

問題1 以下に示すプログラムは、次の処理をするプログラムである 問題 1 次のプログラムの出力結果を a~d の中から選べ public class Problem1 { int i=2; int j=3; System.out.println("i"+j); a) 23,b) 5,c) i3,d) ij 問題 2 次のプログラムの出力結果を a~d の中から選べ public class Problem2 { int a=6; if((a>=2)&&(a

More information

CudaWaveField

CudaWaveField CudaWaveField 2012 3 22 2 CudaWaveField Rel 1.0.0 Rel 1.0 CudaWaveField ( cwfl) / cwfl cwfl http://www.laser.ee.kansai-u.ac.jp/wavefieldtools Note Acrobat Reader 3 I CudaWaveField 9 1 11 1.1 CudaWaveField......................

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

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

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

More information

Prog2_12th

Prog2_12th 2018 年 12 月 13 日 ( 木 ) 実施クラスの継承オブジェクト指向プログラミングの基本的な属性として, 親クラスのメンバを再利用, 拡張, または変更する子クラスを定義することが出来る メンバの再利用を継承と呼び, 継承元となるクラスを基底クラスと呼ぶ また, 基底クラスのメンバを継承するクラスを, 派生クラスと呼ぶ なお, メンバの中でコンストラクタは継承されない C# 言語では,Java

More information

C++ & Bitcoin Core 注意点 Lab - Karl-Johan Alm 2017 Digital Garage. All rights reserved. Redistribution or public display not permitted without w

C++ & Bitcoin Core 注意点 Lab - Karl-Johan Alm 2017 Digital Garage. All rights reserved. Redistribution or public display not permitted without w C++ & Bitcoin Core 注意点 まとめ @DG Lab - Karl-Johan Alm 2017 Digital Garage. All rights reserved. Redistribution or public display not permitted without written permission from Digital Garage. 逃げられる前に言っておこう

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

スライド 1

スライド 1 Boost とその実装技術 ~Boost の薄い話から濃い話まで ~ 自己紹介 C++ スキー Boost スキー D&E 未読 猫スキー 吉田秀彦モドキ アジェンダ Boost について Boost.SharedPtr Boost.SharedPtr の実装技術 Boost.Spirit Boost.Spirit の実装技術 Boost について Boost とは Wikipedia C++ の先駆的な開発者のコミュニティ

More information

program.dvi

program.dvi 2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation

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

ARM gcc Kunihiko IMAI 2009 1 11 ARM gcc 1 2 2 2 3 3 4 3 4.1................................. 3 4.2............................................ 4 4.3........................................

More information

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C (Java/FX ) Java CD Java version 10.0.1 Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas Canvas Eclipse Eclipse M... 1 javafx e(fx)clipse 3.0.0

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または

More information

(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

(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 (Version: 2017/4/18) Intel CPU (kashi@waseda.jp) 1 Intel CPU( AMD CPU) 64bit SIMD Inline Assemler Windows Visual C++ Linux gcc 2 FPU SSE2 Intel CPU double 8087 FPU (floating point number processing unit)

More information

基礎プログラミング2015

基礎プログラミング2015 応用プログラミング 第 11 回 関数の名前 2017 年 11 月 29 日 ( 水 ) 第 12 章 関数の名前 今日の内容 * これまでの関数 必ず main 関数 ( 呼び出し元 ) の前に関数定義をする 宣言した仮引数の数と実引数として渡す値の数は同じ 仮引数の型に合わせた値渡し (1) 関数宣言 : 関数の戻り値の型, 名前, 引数の型のみ先行指定 (2) 多重定義 : 引数が異なる同じ名前の関数の作成

More information

プログラミング基礎

プログラミング基礎 C プログラミング Ⅰ 条件分岐 if~else if~else 文,switch 文 条件分岐 if~else if~else 文 if~else if~else 文 複数の条件で処理を分ける if~else if~else 文の書式 if( 条件式 1){ 文 1-1; 文 1-2; else if( 条件式 2){ 文 2-1; 文 2-2; else { 文 3-1; 文 3-2; 真条件式

More information

untitled

untitled H8/300,H8S,H8SX [H8S,H8/300 Tool Chain Ver6.2.0.0] #define Inline static inline //************************************************** Inline char sil_and_mem(char *mem,char and) return (*((volatile

More information

HABOC manual

HABOC manual HABOC manual Version 2.0 takada@cr.scphys.kyoto-u.ac.jp HABOC とは Event by event 解析用の Framework C++ による coding ANL や FULL の C++ 版を目標 ANL/FULL は Object Oriented な設計概念なので C++ と相性が良い Histogram や視覚化には ROOT(http://root.cern.ch)

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

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

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 (Version: 2013/5/16) Intel CPU (kashi@waseda.jp) 1 Intel CPU( AMD CPU) 64bit SIMD Inline Assemler Windows Visual C++ Linux gcc 2 FPU SSE2 Intel CPU double 8087 FPU (floating point number processing unit)

More information