Finished most of assignment

This commit is contained in:
2025-05-08 14:53:33 +09:00
parent 8912215a06
commit 800b725460
11 changed files with 135 additions and 20 deletions

View File

@@ -1,13 +1,49 @@
\section{演習課題2}
電卓とC言語での演算の違いを比較する。
電卓とC言語での演算の違いを比較する。電卓はCasioの\texttt{fx-CG50(OS バージョン: 03.60.0202)}を使用する。
以下の式を評価する:
\begin{equation}\label{e1}
\frac{5}{2} + \frac{1.5}{2}
\end{equation}
\begin{equation}\label{e2}
\frac{2.5 + 4.0}{5}
\end{equation}
\begin{equation}\label{e3}
\frac{1.5 + 3}{2}
\end{equation}
\begin{equation}\label{e4}
4 + 2 \times \frac{6}{4}
\end{equation}
\begin{equation}\label{e5}
\frac{3.3}{1.1} + \frac{2}{4}
\end{equation}
\subsection{コードリスティング}
\lstinputlisting[language=C,title={演習課題2}]{../programs/comp/main.c}
\subsection{実行結果}
\subsection{結果}
\begin{center}
\includegraphics[width=\textwidth]{./assets/comp.png}
\end{center}
C言語では型変換の影響で評価中に値が真の値からずれ、最終的に演算結果が電卓と異なるものとなった。
\begin{table}
\caption{電卓とC言語での評価結果}
\centering
\begin{tabular}{|ccc|}
\hline
& 電卓 & C言語 \\
\hline \hline
\ref{e1} & 3.25 & 2.750000 \\
\ref{e2} & 1.3 & 1.200000 \\
\ref{e3} & 2.25 & 2 \\
\ref{e4} & 7 & 6.000000 \\
\ref{e5} & 3.5 & 3.227273 \\
\hline
\end{tabular}
\end{table}