added programs

This commit is contained in:
2025-04-30 01:50:13 +09:00
parent 6acb05157f
commit 88519283e1
20 changed files with 132 additions and 1 deletions

13
section/prog3.tex Normal file
View File

@@ -0,0 +1,13 @@
\section{演習1ー8}
プロンプトから読み込んだ2つの整数値の積を表示するプログラム。
\subsection{コードリスティング}
\lstinputlisting[language=C,title={演習1ー8}]{../programs/prog3/main.c}
\subsection{実行結果}
\begin{center}
\includegraphics[width=\textwidth]{./assets/prog3.png}
\end{center}

13
section/prog4.tex Normal file
View File

@@ -0,0 +1,13 @@
\section{演習1ー9}
プロンプトから読み込んだ3つの整数値の和を表示するプログラム。
\subsection{コードリスティング}
\lstinputlisting[language=C,title={演習1ー9}]{../programs/prog4/main.c}
\subsection{実行結果}
\begin{center}
\includegraphics[width=\textwidth]{./assets/prog4.png}
\end{center}

19
section/prog5.tex Normal file
View File

@@ -0,0 +1,19 @@
\section{考察List 1-11}
List 1-11 にて、入力に3.14や0.5などの小数を入力すると出力はどうなるか。
\subsection{コードリスティング}
\lstinputlisting[language=C,title={考察List 1-11}]{../programs/prog5/main.c}
\subsection{実行結果}
\begin{center}
\includegraphics[width=\textwidth]{./assets/prog5.png}
\end{center}
\subsection{考察}
入力した全ての小数が繰り下げられている。
\texttt{\%d}は整数しか表示できず、小数の場合は小数部を切り捨て、整数部のみ表示している。
小数を表示したい場合は\texttt{printf}関数と\texttt{scanf}関数両方の書式を\texttt{\%f}にする必要がある。