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

BIN
assets/p25.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
assets/p26.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -12,7 +12,7 @@ date:
turnin: turnin:
year: 令和7年 year: 令和7年
month: 05月 month: 05月
day: 12 day: 08
school_name: 岐阜工業高等専門学校 school_name: 岐阜工業高等専門学校
department: 電子制御工学科 department: 電子制御工学科
@@ -22,13 +22,12 @@ professor: 岡崎 憲一
paper_config: paper_config:
include_cover_page: true include_cover_page: true
include_table_of_contents: true include_table_of_contents: true
use_bib: false use_bib: true
use_additional_packages: false use_additional_packages: true
show_compiled_time: true show_compiled_time: true
# packages: packages:
# - { name: "pkg", options: "options,inside,brackets" } - { name: "wrapfig", options: "" }
# - { name: "pkg-wo-opt", options: "" }
sections: sections:
- { path: 'section/introduction.tex', newpg: false } - { path: 'section/introduction.tex', newpg: false }

42
main.tex Normal file
View File

@@ -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}

BIN
output/main.pdf Normal file

Binary file not shown.

View File

@@ -1,9 +1,8 @@
@online{example, @online{cppref_printf,
title = {Example Entry}, title = {printf, fprintf, sprintf, snprintf, printf\_s, fprintf\_s, sprintf\_s, snprintf\_s},
author = {Inc., Example}, 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},
organization = {Example, Inc.}, url = {https://en.cppreference.com/w/c/io/fprintf},
url = {https://www.example.com}, year = {2025},
year = {1970},
month = {01}, month = {01},
urldate = {1970-01-01} urldate = {2025-05-08}
} }

View File

@@ -1,13 +1,49 @@
\section{演習課題2} \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{コードリスティング} \subsection{コードリスティング}
\lstinputlisting[language=C,title={演習課題2}]{../programs/comp/main.c} \lstinputlisting[language=C,title={演習課題2}]{../programs/comp/main.c}
\subsection{実行結果} \subsection{結果}
\begin{center} C言語では型変換の影響で評価中に値が真の値からずれ、最終的に演算結果が電卓と異なるものとなった。
\includegraphics[width=\textwidth]{./assets/comp.png}
\end{center} \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}

View File

@@ -1 +1,12 @@
\section{はじめに} \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}

View File

@@ -1,6 +1,6 @@
\section{演習課題1 演習2ー5} \section{演習課題1 演習2ー5}
2つの整数値を読み込み、前者の値が後者の値の何%であるかを倍精度浮動小数点数として表示するプログラム。 2つの整数値を読み込み、前者の値が後者の値の何\%であるかを倍精度浮動小数点数として表示するプログラム。
\subsection{コードリスティング} \subsection{コードリスティング}

View File

@@ -1,6 +1,6 @@
\section{演習課題1 演習2ー6} \section{演習課題1 演習2ー6}
身長を整数値として読み込み、標準体重を実数小数点以下1桁として表示するプログラム。なお標準体重は$0.9(height - 100)$で求めるものとする。 身長を整数値として読み込み、標準体重を実数小数点以下1桁として表示するプログラム。\\なお標準体重は$0.9(height - 100)$で求めるものとする。
\subsection{コードリスティング} \subsection{コードリスティング}

View File

@@ -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("%<a>.<b>f", x);
// 小数点以上最低 a 桁、小数点以下最低 b 桁表示する
\end{lstlisting}