2001-12-01から1ヶ月間の記事一覧
『明解C言語 入門編』 in Python 柴田望洋『明解C言語 入門編』を Python で実装してみます。 1. まずは慣れよう 000.整数値 15 と 37 の和を表示する 001.整数値 15 から 37 を引いた値を表示する 002.整数値 15 と 37 の和を親切に表示する 003.2つの変…
明解C言語 入門編 > 12. 構造体 > ポインタのソート Python # coding: Shift_JIS NINSU = 5 def compare_height(x, y): if (x["height"] > y["height"]): return 1 if (x["height"] < y["height"]): return -1 return 0 def compare_weight(x, y): if (x["w…
明解C言語 入門編 > 12. 構造体 > 構造体の動的配列 (realloc) Python
明解C言語 入門編 > 12. 構造体 > 構造体の動的配列 (malloc) Python # coding: Shift_JIS NINSU = 5 def compare_height(x, y): if (x["height"] > y["height"]): return 1 if (x["height"] < y["height"]): return -1 return 0 def compare_weight(x, y):…
明解C言語 入門編 > 12. 構造体 > 5人の学生を 身長・体重で ソート (関数ポインタ) Python # coding: Shift_JIS NINSU = 5 def compare_height(x, y): if (x["height"] > y["height"]): return 1 if (x["height"] < y["height"]): return -1 return 0 def…
明解C言語 入門編 > 12. 構造体 > 5人の学生を 身長で ソート (構造体) Python # coding: Shift_JIS NINSU = 5 def sort(data, n): k = n - 1 while (k >= 0): j = -1; for i in range(1, k + 1, 1): if (data[i - 1]["height"] > data[i]["height"]): j =…
明解C言語 入門編 > 12. 構造体 > 構造体を返す関数 Python
明解C言語 入門編 > 12. 構造体 > 構造体と typedef Python
明解C言語 入門編 > 12. 構造体 > -> 演算子 Python
明解C言語 入門編 > 12. 構造体 > 構造体の受け渡し Python # coding: Shift_JIS def hiroko(std): std["height"] = 180; std["weight"] = 80; sanaka = {"name":"Sanaka", "height":175} print "氏名:%s" % sanaka["name"] print "身長:%d" % sanaka["he…
明解C言語 入門編 > 12. 構造体 > 構造体のメンバの初期化 Python # coding: Shift_JIS sanaka = {"name":"Sanaka", "height":175, "weight":60.5} print "氏名:%s" % sanaka["name"] print "身長:%d" % sanaka["height"] print "体重:%f" % sanaka["wei…