diff --git a/assets/abs-floating.png b/assets/abs-floating.png new file mode 100644 index 0000000..65d34be Binary files /dev/null and b/assets/abs-floating.png differ diff --git a/document.yaml b/document.yaml index 00a8dbd..2697b15 100644 --- a/document.yaml +++ b/document.yaml @@ -39,5 +39,6 @@ sections: - { path: 'section/lst36.tex', newpg: true } - { path: 'section/lst37.tex', newpg: true } - { path: 'section/lst38.tex', newpg: true } - - { path: 'section/abs.tex', newpg: false } + - { path: 'section/abs.tex', newpg: true } + - { path: 'section/abs-floating.tex', newpg: false } diff --git a/main.tex b/main.tex index 8eaaaac..fc49814 100644 --- a/main.tex +++ b/main.tex @@ -44,6 +44,9 @@ \newpage \input{section/abs.tex} + \newpage + + \input{section/abs-floating.tex} \compiledTime \end{document} diff --git a/output/main-opt-final.pdf b/output/main-opt-final.pdf index 47550ec..92adbae 100644 Binary files a/output/main-opt-final.pdf and b/output/main-opt-final.pdf differ diff --git a/output/main.pdf b/output/main.pdf index 5c84fb0..05da2f5 100644 Binary files a/output/main.pdf and b/output/main.pdf differ diff --git a/programs/abs-floating/info.json b/programs/abs-floating/info.json new file mode 100644 index 0000000..58a0031 --- /dev/null +++ b/programs/abs-floating/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習課題2 浮動小数点数版", + "description": "倍精度浮動小数点数を読み込み、その絶対値を出力するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/abs-floating.png" + }, + "note": "" +} diff --git a/programs/abs-floating/main b/programs/abs-floating/main new file mode 100755 index 0000000..02e7a56 Binary files /dev/null and b/programs/abs-floating/main differ diff --git a/programs/abs-floating/main.c b/programs/abs-floating/main.c new file mode 100644 index 0000000..4fed4c4 --- /dev/null +++ b/programs/abs-floating/main.c @@ -0,0 +1,17 @@ +#include + +int main(void) { + double x, y; + + printf("Input floating point: "); + scanf("%lf", &x); + + y = x; + + if (y < 0.0) + y = -y; + + printf("Absolute value of %lf is %lf.\n", x, y); + + return 0; +} diff --git a/section/abs-floating.tex b/section/abs-floating.tex new file mode 100644 index 0000000..cbe5e30 --- /dev/null +++ b/section/abs-floating.tex @@ -0,0 +1,13 @@ +\section{演習課題2 浮動小数点数版} + +倍精度浮動小数点数を読み込み、その絶対値を出力するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習課題2 浮動小数点数版}]{../programs/abs-floating/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/abs-floating.png} +\end{center}