diff --git a/Makefile b/Makefile index a168c6f..7605ed6 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ BIBFLAGS := --input-directory=$(OUTDIR) --output-directory=$(OUTDIR)/ PRINTFORMAT := "\033[1;92;49m%s\033[m\n" -USE_MARKDOWN := true +USE_MARKDOWN := false MARKDOWNS := $(wildcard markdown/*.md) MARKDOWN_OUTPUTS := $(patsubst markdown/%.md,md-out/%.tex,$(MARKDOWNS)) diff --git a/assets/a1.png b/assets/a1.png new file mode 100644 index 0000000..6eebbb6 Binary files /dev/null and b/assets/a1.png differ diff --git a/assets/a2.png b/assets/a2.png new file mode 100644 index 0000000..18c0592 Binary files /dev/null and b/assets/a2.png differ diff --git a/assets/a3.png b/assets/a3.png new file mode 100644 index 0000000..0ad1834 Binary files /dev/null and b/assets/a3.png differ diff --git a/assets/a4.png b/assets/a4.png new file mode 100644 index 0000000..ed091cd Binary files /dev/null and b/assets/a4.png differ diff --git a/assets/a5.png b/assets/a5.png new file mode 100644 index 0000000..5b4d4ec Binary files /dev/null and b/assets/a5.png differ diff --git a/document.yaml b/document.yaml index c49334c..79d8fb1 100644 --- a/document.yaml +++ b/document.yaml @@ -1,28 +1,28 @@ doc_class: nitreport -title: Insert Title Here +title: 第11回課題 author: - name: 高専 太郎 - student_id: 0000-01 - seating_number: 1 + name: 柴田健琉 + student_id: 2024D14 + seating_number: 15 date: year: 令和7年 - month: aa月 - day: bb日 + month: 06月 + day: 26日 turnin: year: 令和7年 - month: cc月 - day: dd日 + month: 06月 + day: 26日 -school_name: abc高専 -department: 一般科 -subject: 〇〇概論 -professor: □□教員 +school_name: 岐阜工業高等専門学校 +department: 電子制御工学科 +subject: 情報処理I +professor: 岡崎憲一 paper_config: include_cover_page: true include_table_of_contents: true - use_bib: false + use_bib: true use_additional_packages: false show_compiled_time: true @@ -31,6 +31,11 @@ paper_config: # - { name: "pkg-wo-opt", options: "" } sections: - - { path: 'section/introduction.tex', newpg: true } - - { path: 'md-out/test.tex', newpg: false } + - { path: 'section/introduction.tex', newpg: false } + - { path: 'section/syntax.tex', newpg: true } + - { path: 'section/a1.tex', newpg: true } + - { path: 'section/a2.tex', newpg: true } + - { path: 'section/a3.tex', newpg: true } + - { path: 'section/a4.tex', newpg: true } + - { path: 'section/a5.tex', newpg: true } diff --git a/main.tex b/main.tex new file mode 100644 index 0000000..eb25665 --- /dev/null +++ b/main.tex @@ -0,0 +1,46 @@ +\documentclass{class/nitreport} + +\reporttitle{第11回課題} +\reportauthor{柴田健琉} +\studentid{2024D14} +\seatingnum{15} +\reportdate{令和7年}{06月}{26日} +\turnindate{令和7年}{06月}{26日} +\schoolname{岐阜工業高等専門学校} +\department{電子制御工学科} +\subject{情報処理I} +\professor{岡崎憲一} + +\pagenumbering{roman} + +\begin{document} + \coverpage + + \tableofcontents + \newpage + \pagenumbering{arabic} + + \input{section/introduction.tex} + + \input{section/syntax.tex} + \newpage + + \input{section/a1.tex} + \newpage + + \input{section/a2.tex} + \newpage + + \input{section/a3.tex} + \newpage + + \input{section/a4.tex} + \newpage + + \input{section/a5.tex} + \newpage + + \printbibliography[heading=bibintoc,title={参考文献}] + + \compiledTime +\end{document} diff --git a/markdown/test.md b/markdown/test.md deleted file mode 100644 index 9fdd1bf..0000000 --- a/markdown/test.md +++ /dev/null @@ -1,18 +0,0 @@ -# Hi - -| x | y | -| --- | --- | -| 0 | 0 | -| 1 | 1 | -| 2 | 2 | -| 3 | 3 | -| 4 | 4 | - -* i1 -* i2 -* i3 - -1. n1 -2. n2 -3. n3 - diff --git a/output/main.pdf b/output/main.pdf new file mode 100644 index 0000000..6826c8a Binary files /dev/null and b/output/main.pdf differ diff --git a/programs/a1/info.json b/programs/a1/info.json new file mode 100644 index 0000000..03dd1d9 --- /dev/null +++ b/programs/a1/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "課題1", + "description": "入力した整数値が1桁の自然数に含まれるかを判定するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/a1.png" + }, + "note": "" +} diff --git a/programs/a1/main b/programs/a1/main new file mode 100755 index 0000000..e205d30 Binary files /dev/null and b/programs/a1/main differ diff --git a/programs/a1/main.c b/programs/a1/main.c new file mode 100644 index 0000000..c681bad --- /dev/null +++ b/programs/a1/main.c @@ -0,0 +1,16 @@ +#include + +int main(void) { + int n; + + printf("Input integer: "); + scanf("%d", &n); + + if (n <= 10 && n > 0) { + printf("%d is one digit natural number.\n", n); + } else { + printf("%d is not one digit natural number.\n", n); + } + + return 0; +} diff --git a/programs/a2/info.json b/programs/a2/info.json new file mode 100644 index 0000000..eb3ec47 --- /dev/null +++ b/programs/a2/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "課題2", + "description": "入力した3つの整数値が小さい順または等価になっているかを検証するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/a2.png" + }, + "note": "" +} diff --git a/programs/a2/main b/programs/a2/main new file mode 100755 index 0000000..d3e33d0 Binary files /dev/null and b/programs/a2/main differ diff --git a/programs/a2/main.c b/programs/a2/main.c new file mode 100644 index 0000000..4b02b85 --- /dev/null +++ b/programs/a2/main.c @@ -0,0 +1,24 @@ +#include + +int main(void) { + int a, b, c; + + printf("Input integer #1: "); + scanf("%d", &a); + printf("Input integer #2: "); + scanf("%d", &b); + printf("Input integer #3: "); + scanf("%d", &c); + + if (a <= b) { + if (b <= c) { + puts("OK"); + } else { + puts("NG"); + } + } else { + puts("NG"); + } + + return 0; +} diff --git a/programs/a3/info.json b/programs/a3/info.json new file mode 100644 index 0000000..ca18e88 --- /dev/null +++ b/programs/a3/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "課題3", + "description": "二次方程式の解の種類を判別するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/a3.png" + }, + "note": "上記のコードリストは浮動少数点数の演算・変数格納時の誤差を考慮していない。\\n考慮する場合は\\\\texttt{float.h}内の\\\\texttt{DBL_MIN}や\\\\texttt{DBL_EPSILON}を用いた判別処理が必要である。" +} diff --git a/programs/a3/main b/programs/a3/main new file mode 100755 index 0000000..f61b546 Binary files /dev/null and b/programs/a3/main differ diff --git a/programs/a3/main.c b/programs/a3/main.c new file mode 100644 index 0000000..e5ac960 --- /dev/null +++ b/programs/a3/main.c @@ -0,0 +1,24 @@ +#include + +int main(void) { + double a, b, c, D; + + printf("a: "); + scanf("%lf", &a); + printf("b: "); + scanf("%lf", &b); + printf("c: "); + scanf("%lf", &c); + + D = b * b - 4 * a * c; + + if (D == 0.0) { + puts("Superposition"); + } else if (D < 0.0) { + puts("Two complex answers"); + } else if (D > 0.0) { + puts("Two real answers"); + } + + return 0; +} diff --git a/programs/a4/info.json b/programs/a4/info.json new file mode 100644 index 0000000..05c2965 --- /dev/null +++ b/programs/a4/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "課題4", + "description": "1年の月の日数を返すプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/a4.png" + }, + "note": "" +} diff --git a/programs/a4/main b/programs/a4/main new file mode 100755 index 0000000..4672b2f Binary files /dev/null and b/programs/a4/main differ diff --git a/programs/a4/main.c b/programs/a4/main.c new file mode 100644 index 0000000..c7d0b80 --- /dev/null +++ b/programs/a4/main.c @@ -0,0 +1,29 @@ +#include + +int main(void) { + int month; + + printf("Input month: "); + scanf("%d", &month); + + if (month < 1 || month > 12) { + puts("Unknown month"); + return 1; + } + + switch (month) { + case 2: + puts("28 days"); + break; + case 4: + case 6: + case 9: + case 11: + puts("30 days"); + break; + default: + puts("31 days"); + } + + return 0; +} diff --git a/programs/a5/info.json b/programs/a5/info.json new file mode 100644 index 0000000..6835812 --- /dev/null +++ b/programs/a5/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "課題5", + "description": "第10回の課題「簡易電卓」を繰り返し計算できるように変更したプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/a5.png" + }, + "note": "" +} diff --git a/programs/a5/main b/programs/a5/main new file mode 100755 index 0000000..60d066d Binary files /dev/null and b/programs/a5/main differ diff --git a/programs/a5/main.c b/programs/a5/main.c new file mode 100644 index 0000000..57addc4 --- /dev/null +++ b/programs/a5/main.c @@ -0,0 +1,54 @@ +#include + +#define ADD 1 +#define SUB 2 +#define MUL 3 +#define DIV 4 + +int main(void) { + double a, b; + int op; + int retry = 1; + + do { + printf("Input first number: "); + scanf("%lf", &a); + printf("Input second number: "); + scanf("%lf", &b); + + printf("Select Operation:\n" + "[1]: Addition\n" + "[2]: Subtraction\n" + "[3]: Multiplication\n" + "[4]: Division\n" + "> "); + scanf("%d", &op); + + switch (op) { + case ADD: + printf("ANS: %lf\n", a + b); + break; + case SUB: + printf("ANS: %lf\n", a - b); + break; + case MUL: + printf("ANS: %lf\n", a * b); + break; + case DIV: + if (b == 0.0) { + puts("Zero Division"); + return 1; + } + printf("ANS: %lf\n", a / b); + break; + default: + puts("Undefined Operation"); + return 1; + } + + printf("Retry? [1/0]: "); + scanf("%d", &retry); + } while (retry == 1); + + return 0; +} diff --git a/references.bib b/references.bib index bc328a4..cb683be 100644 --- a/references.bib +++ b/references.bib @@ -1,9 +1,6 @@ -@online{example, - title = {Example Entry}, - author = {Inc., Example}, - organization = {Example, Inc.}, - url = {https://www.example.com}, - year = {1970}, - month = {01}, - urldate = {1970-01-01} +@online{cppref_float, + title = {Standard library header }, + author = {cppreference}, + url = {https://en.cppreference.com/w/c/header/float.html}, + urldate = {2025-06-26} } diff --git a/section/a1.tex b/section/a1.tex new file mode 100644 index 0000000..c9a3c26 --- /dev/null +++ b/section/a1.tex @@ -0,0 +1,13 @@ +\section{課題1} + +入力した整数値が1桁の自然数に含まれるかを判定するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={課題1}]{../programs/a1/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/a1.png} +\end{center} diff --git a/section/a2.tex b/section/a2.tex new file mode 100644 index 0000000..14f8340 --- /dev/null +++ b/section/a2.tex @@ -0,0 +1,13 @@ +\section{課題2} + +入力した3つの整数値が小さい順または等価になっているかを検証するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={課題2}]{../programs/a2/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/a2.png} +\end{center} diff --git a/section/a3.tex b/section/a3.tex new file mode 100644 index 0000000..b1d3347 --- /dev/null +++ b/section/a3.tex @@ -0,0 +1,27 @@ +\section{課題3} + +二次方程式の解の種類を判別するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={課題3}]{../programs/a3/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/a3.png} +\end{center} + +\subsection{考察} + +上記のコードリストは浮動少数点数の演算・変数格納時の誤差を考慮していない。 +考慮する場合は\texttt{float.h}内の\texttt{DBL\_MIN}や\texttt{DBL\_EPSILON}を用いた判別処理が必要である\cite{cppref_float}。 + +\begin{lstlisting}[language=C,title={誤差を考慮した比較}] +#include +#include + +if (D == DBL_EPSILON * fmax(1, fmax(fabs(D), 0.0))) { + puts("superposition"); +} +\end{lstlisting} diff --git a/section/a4.tex b/section/a4.tex new file mode 100644 index 0000000..9c284be --- /dev/null +++ b/section/a4.tex @@ -0,0 +1,13 @@ +\section{課題4} + +1年の月の日数を返すプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={課題4}]{../programs/a4/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/a4.png} +\end{center} diff --git a/section/a5.tex b/section/a5.tex new file mode 100644 index 0000000..ff26453 --- /dev/null +++ b/section/a5.tex @@ -0,0 +1,13 @@ +\section{課題5} + +第10回の課題「簡易電卓」を繰り返し計算できるように変更したプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={課題5}]{../programs/a5/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/a5.png} +\end{center} diff --git a/section/introduction.tex b/section/introduction.tex index 3386076..b03c6d7 100644 --- a/section/introduction.tex +++ b/section/introduction.tex @@ -1,70 +1,12 @@ \section{はじめに} -Start Writing! +\subsection{実行環境} -Use lualatex + biber to compile. +この課題のプログラムは以下の環境で動作することが確認されている: -Test Bib\cite{example} - -いろはにほへと ちりぬるを - -{\gtfamily \sffamily \LaTeX で自由な組版を。} - -{\gtfamily \sffamily Write freely with \LaTeX{}.} - -{\ttfamily LaTeX shall be free forever!} - -\noindent -この行のテキストは四十二字です。ああああああああああああああああああああああああああいいいい - -\defaultlistingstyle - -\begin{lstlisting}[language=C, caption=Basic Hello World] -#include - -int square(int n) { - return n*n; -} - -int main(int argc, char** argv) { - char* msg = "Hello World"; - int x = 3; - int y = square(x); - printf("%s\n", msg); - printf("f(x) = x^2; x: %d, y: %d\n", x, y); - return 0; -} -\end{lstlisting} - -\begin{displaymath} - \int_{a}^{b} f(x) \,dx = F(b)-F(a) -\end{displaymath} - \begin{itemize} - \item C - \item Python - \item Javascript - \item Rust - \item Haskell + \item OS: Arch Linux + \item CPU アーキテクチャ: \texttt{x86\_64} + \item C コンパイラ: \texttt{gcc バージョン 14.2.1 20250322 (GCC)} + \item C コンパイラオプション: \texttt{-Wall} \end{itemize} - -\begin{enumerate} - \item lualatex .tex - \item biber - \item lualatex .tex - \item lualatex .tex -\end{enumerate} - -\newpage - -\section{Section} - -section - -\subsection{Sub Section} - -sub section - -\paragraph{Paragraph} - -paragraph diff --git a/section/syntax.tex b/section/syntax.tex new file mode 100644 index 0000000..56818c6 --- /dev/null +++ b/section/syntax.tex @@ -0,0 +1,12 @@ +\section{今回の構文} + +\subsection{\texttt{do-while}文} + +\texttt{do-while}文は繰り返しを行う処理の一つでブロック内の処理を終えるたびにループの条件式を評価する。 + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={\texttt{do-while}文}] +do { + 文... +} while (式); +\end{lstlisting}