1 名前:BASIC mailto:fh [2006/01/09(月) 15:35:00 ] N人分のデータ(氏名、体重、身長、年齢)がDATA文で入力されているプログラムが ある。これを用いて次のプログラムをBASICで作成しなさい 身長が160CM以上で170cm未満の人の名前を表示する
81 名前:デフォルトの名無しさん mailto:sage [2006/05/20(土) 12:39:42 ] >>80 残りのUI関係は自分でやっとくれ。 Function lcm(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer) As Integer Dim answer As Integer answer = x Do If ((answer Mod y = 0) And (answer Mod z = 0)) Then Exit Do answer = answer + x Loop lcm = answer End Function
82 名前:デフォルトの名無しさん mailto:sage [2006/05/20(土) 12:43:19 ] おまけ: ユークリッドの互除法を使った場合 Function gcd(ByVal a As Integer, ByVal b As Integer) As Integer Dim c As Integer Do While b <> 0 c = a Mod b a = b b = c Loop gcd = a End Function Function lcm(ByVal a As Integer, ByVal b As Integer) As Integer lcm = a * b / gcd(a, b) End Function Function lcm3(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer) As Integer Dim d As Integer d = lcm(a, b) lcm3 = lcm(c, d) End Function