diff --git a/assets/p25.png b/assets/p25.png new file mode 100644 index 0000000..417061a Binary files /dev/null and b/assets/p25.png differ diff --git a/assets/p26.png b/assets/p26.png new file mode 100644 index 0000000..22455fd Binary files /dev/null and b/assets/p26.png differ diff --git a/document.yaml b/document.yaml index abae6f8..897774a 100644 --- a/document.yaml +++ b/document.yaml @@ -12,7 +12,7 @@ date: turnin: year: 令和7年 month: 05月 - day: 12日 + day: 08日 school_name: 岐阜工業高等専門学校 department: 電子制御工学科 @@ -22,13 +22,12 @@ professor: 岡崎 憲一 paper_config: include_cover_page: true include_table_of_contents: true - use_bib: false - use_additional_packages: false + use_bib: true + use_additional_packages: true show_compiled_time: true -# packages: -# - { name: "pkg", options: "options,inside,brackets" } -# - { name: "pkg-wo-opt", options: "" } +packages: + - { name: "wrapfig", options: "" } sections: - { path: 'section/introduction.tex', newpg: false } diff --git a/main.tex b/main.tex new file mode 100644 index 0000000..a247953 --- /dev/null +++ b/main.tex @@ -0,0 +1,42 @@ +\documentclass{class/nitreport} + +\reporttitle{第5回課題} +\reportauthor{柴田 健琉} +\studentid{2024D14} +\seatingnum{15} +\reportdate{令和7年}{05月}{08日} +\turnindate{令和7年}{05月}{08日} +\schoolname{岐阜工業高等専門学校} +\department{電子制御工学科} +\subject{情報処理I} +\professor{岡崎 憲一} + +\usepackage{wrapfig} + +\pagenumbering{roman} + +\begin{document} + \coverpage + + \tableofcontents + \newpage + \pagenumbering{arabic} + + \input{section/introduction.tex} + + \input{section/syntax.tex} + \newpage + + \input{section/p25.tex} + \newpage + + \input{section/p26.tex} + \newpage + + \input{section/comp.tex} + \newpage + + \printbibliography[heading=bibintoc,title={参考文献}] + + \compiledTime +\end{document} diff --git a/output/main.pdf b/output/main.pdf new file mode 100644 index 0000000..53c7fab Binary files /dev/null and b/output/main.pdf differ diff --git a/references.bib b/references.bib index bc328a4..f130f31 100644 --- a/references.bib +++ b/references.bib @@ -1,9 +1,8 @@ -@online{example, - title = {Example Entry}, - author = {Inc., Example}, - organization = {Example, Inc.}, - url = {https://www.example.com}, - year = {1970}, +@online{cppref_printf, + title = {printf, fprintf, sprintf, snprintf, printf\_s, fprintf\_s, sprintf\_s, snprintf\_s}, + author = {Eendy and P12bot and P12 and Newatthis and Cubbi and Oli and LittleFlower and D41D8CD98F and Mission, Space and Traceon and YexuanXiao and Yaossg}, + url = {https://en.cppreference.com/w/c/io/fprintf}, + year = {2025}, month = {01}, - urldate = {1970-01-01} + urldate = {2025-05-08} } diff --git a/section/comp.tex b/section/comp.tex index 43bbe58..90a9a8d 100644 --- a/section/comp.tex +++ b/section/comp.tex @@ -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} diff --git a/section/introduction.tex b/section/introduction.tex index 023e039..a700f4d 100644 --- a/section/introduction.tex +++ b/section/introduction.tex @@ -1 +1,12 @@ \section{はじめに} + +\subsection{実行環境} + +この課題のプログラムは以下の環境で動作することが確認されている: + +\begin{itemize} + \item OS: Arch Linux + \item CPU アーキテクチャ: \texttt{x86\_64} + \item C コンパイラ: \texttt{gcc バージョン 15.1.1 20250425 (GCC)} + \item C コンパイラオプション: \texttt{-Wall <ソースコード名> -o <実行ファイル名>} +\end{itemize} diff --git a/section/p25.tex b/section/p25.tex index 0e2f906..2215feb 100644 --- a/section/p25.tex +++ b/section/p25.tex @@ -1,6 +1,6 @@ \section{演習課題1 演習2ー5} -2つの整数値を読み込み、前者の値が後者の値の何%であるかを倍精度浮動小数点数として表示するプログラム。 +2つの整数値を読み込み、前者の値が後者の値の何\%であるかを倍精度浮動小数点数として表示するプログラム。 \subsection{コードリスティング} diff --git a/section/p26.tex b/section/p26.tex index 54ea8d4..449010f 100644 --- a/section/p26.tex +++ b/section/p26.tex @@ -1,6 +1,6 @@ \section{演習課題1 演習2ー6} -身長を整数値として読み込み、標準体重を実数小数点以下1桁として表示するプログラム。なお標準体重は$0.9(height - 100)$で求めるものとする。 +身長を整数値として読み込み、標準体重を実数小数点以下1桁として表示するプログラム。\\なお標準体重は$0.9(height - 100)$で求めるものとする。 \subsection{コードリスティング} diff --git a/section/syntax.tex b/section/syntax.tex index e69de29..8e8cd6c 100644 --- a/section/syntax.tex +++ b/section/syntax.tex @@ -0,0 +1,28 @@ +\section{今回の構文} + +\subsection{型変換} + +数値型やポインタ型は別の数値型やポインタ型に変換できる。 +このとき、変換先の型の\\有効範囲を考慮する必要がある。 +有効範囲を超える・下回る場合は警告なしで値が丸められる。 + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={暗黙の型変換}] +<型名1> <変数名> = <型名2となる式>; +\end{lstlisting} + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={明示的型変換}] +<型名1> <変数名> = (<型名2>)(<式>); +\end{lstlisting} + +\subsection{小数点数書式} + +\texttt{printf}関数では表示する小数点数の桁数を書式から指定できる。\cite{cppref_printf} + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={小数点数書式}] +double x; +printf("%.f", x); +// 小数点以上最低 a 桁、小数点以下最低 b 桁表示する +\end{lstlisting}