0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DNCLで三角形・四角形の面積を求める

0
Posted at

はじめに

この記事は 共通テスト手順記述標準言語 (DNCL) Advent Calendar 2025 の19日目の記事です。

DNCLで四角形や三角形の辺の長さから面積を求めます。

ヘロンの公式

三角形の3辺の長さをabcとします。s = (a + b + c) / 2とすると、三角形の面積は

S = \sqrt{s(s-a)(s-b)(s-c)} \\

と表されます。

詳しくは下の記事をご覧ください。

ブラーマグプタの公式

円に内接する四角形にはヘロンの公式と似た面積公式があります。
四角形の4辺の長さをabcdとします。s = (a + b + c + d) / 2とすると、四角形の面積は

S = \sqrt{(s-a)(s-b)(s-c)(s-d)} \\

と表されます。
d = 0のときはs - d = sになるため、ヘロンの公式と一致します。
ブラーマグプラの公式も下の記事に詳しく書かれています。

面積を求めよう

四角形は円に内接している前提で利用します。三角形のときはd = 0とします。
また、関数平方根(数値)数値の平方根を返します。

a ← 3
b ← 4
c ← 5
d ← 8

s ← (a + b + c + d) ÷ 2
平方根((s - a) * (s - b) * (s - c) * (s - d)) を表示する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?