diff --git a/assets/prog1.png b/assets/prog1.png new file mode 100644 index 0000000..c5f7bd4 Binary files /dev/null and b/assets/prog1.png differ diff --git a/assets/prog2.png b/assets/prog2.png new file mode 100644 index 0000000..eb9289a Binary files /dev/null and b/assets/prog2.png differ diff --git a/document.yaml b/document.yaml index 7c67f8c..6fa99e3 100644 --- a/document.yaml +++ b/document.yaml @@ -1,18 +1,18 @@ doc_class: nitreport -title: Insert Title Here +title: 第3回課題 author: - name: 高専 太郎 - student_id: 0000-01 + name: 柴田 健琉 + student_id: 15(2年生) date: year: 令和7年 - month: aa月 - day: bb日 + month: 04月 + day: 27日 -school_name: abc高専 -department: 一般科 -subject: 〇〇概論 -professor: □□教員 +school_name: 岐阜工業高等専門学校 +department: 電子制御工学科 +subject: 情報処理I +professor: 岡崎 憲一 page_config: include_cover_page: true @@ -21,6 +21,7 @@ page_config: show_compiled_time: true 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/prog1.tex', newpg: true } + - { path: 'section/prog2.tex', newpg: true } diff --git a/main.tex b/main.tex new file mode 100644 index 0000000..749c101 --- /dev/null +++ b/main.tex @@ -0,0 +1,37 @@ +\documentclass{class/nitreport} + +\reporttitle{第3回課題} +\reportauthor{柴田 健琉} +\studentid{15(2年生)} +\reportdate{令和7年}{04月}{27日} +\schoolname{岐阜工業高等専門学校} +\department{電子制御工学科} +\subject{情報処理I} +\professor{岡崎 憲一} + +\usepackage{ascmac} + +\pagenumbering{roman} + +\begin{document} + \coverpage + + \tableofcontents + \newpage + \pagenumbering{arabic} + + \input{section/introduction.tex} + + \input{section/syntax.tex} + \newpage + + \input{section/prog1.tex} + \newpage + + \input{section/prog2.tex} + \newpage + + \printbibliography + + \compiledTime +\end{document} diff --git a/output/main-opt-final.pdf b/output/main-opt-final.pdf new file mode 100644 index 0000000..3acc3df Binary files /dev/null and b/output/main-opt-final.pdf differ diff --git a/output/main.pdf b/output/main.pdf new file mode 100644 index 0000000..f606241 Binary files /dev/null and b/output/main.pdf differ diff --git a/programs/prog1/info.json b/programs/prog1/info.json new file mode 100644 index 0000000..95ecd5f --- /dev/null +++ b/programs/prog1/info.json @@ -0,0 +1,9 @@ +{ + "name": "演習1ー5", + "description": "プロンプトから読み込んだ整数値に13を加えた値を表示するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/prog1.png" + }, + "note": "" +} diff --git a/programs/prog1/main b/programs/prog1/main new file mode 100755 index 0000000..cdb65d5 Binary files /dev/null and b/programs/prog1/main differ diff --git a/programs/prog1/main.c b/programs/prog1/main.c new file mode 100644 index 0000000..886b837 --- /dev/null +++ b/programs/prog1/main.c @@ -0,0 +1,12 @@ +#include + +int main(void) { + int x = 0; + + printf("Input integer: x = "); + scanf("%d", &x); + + printf("Result: x + 13 = %d\n", x + 13); + + return 0; +} diff --git a/programs/prog2/info.json b/programs/prog2/info.json new file mode 100644 index 0000000..133adda --- /dev/null +++ b/programs/prog2/info.json @@ -0,0 +1,9 @@ +{ + "name": "演習1ー6", + "description": "プロンプトから読み込んだ整数値から7を減じた値を表示するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/prog2.png" + }, + "note": "" +} diff --git a/programs/prog2/main b/programs/prog2/main new file mode 100755 index 0000000..214a53e Binary files /dev/null and b/programs/prog2/main differ diff --git a/programs/prog2/main.c b/programs/prog2/main.c new file mode 100644 index 0000000..6506f32 --- /dev/null +++ b/programs/prog2/main.c @@ -0,0 +1,12 @@ +#include + +int main(void) { + int x = 0; + + printf("Input integer: x = "); + scanf("%d", &x); + + printf("Result: x - 7 = %d\n", x - 7); + + return 0; +} diff --git a/references.bib b/references.bib index bc328a4..07ecd77 100644 --- a/references.bib +++ b/references.bib @@ -1,9 +1,16 @@ -@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_scanf, + title = {scanf, fscanf, sscanf, scanf\_s, fscanf\_s, sscanf\_s}, + author = {Eendy and P12bot and P12 and Cubbi and Newatthis and Himanshujha199640 and LittleFlower and D41D8CD98F and Mission, Space}, + url = {https://en.cppreference.com/w/c/io/fscanf}, + year = {2022}, + month = {07}, + urldate = {2025-04-24} +} +@online{cppref_stdio, + title = {Standard library header }, + author = {Mission, Space}, + url = {https://en.cppreference.com/w/c/header/stdio}, + year = {2025}, + month = {02}, + urldate = {2025-04-27} } diff --git a/script/info-proc-programs.bash b/script/info-proc-programs.bash index d538b47..8d4a59e 100644 --- a/script/info-proc-programs.bash +++ b/script/info-proc-programs.bash @@ -50,7 +50,7 @@ function writeSection () { local x=0 local res="" - [[ $note == "\n\nnull" ]] && note="" + [[ $note == "\n\nnull" || $note == "\n\n" ]] && note="" res+="\\section{$sectionName}\n\n$description\n\n\\subsection{コードリスティング}\n\n" @@ -64,6 +64,8 @@ function writeSection () { x=$(($x+1)) done + res+="\n\\section{実行結果}\n" + if [[ $outType == "screenshot" ]]; then res+="\n\\\\begin{center}\n \\includegraphics[width=\\\\textwidth]{$outContent}\n\\\\end{center}" elif [[ $outType == "text" ]]; then diff --git a/section/introduction.tex b/section/introduction.tex index 6347545..ab978c7 100644 --- a/section/introduction.tex +++ b/section/introduction.tex @@ -1,67 +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!} - -\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 (GCC) 14.2.1 20250207} + \item C コンパイラフラグ: \texttt{-Wall <ソースコード名> -o <プログラム名>} \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/prog1.tex b/section/prog1.tex new file mode 100644 index 0000000..28f782e --- /dev/null +++ b/section/prog1.tex @@ -0,0 +1,13 @@ +\section{演習1ー5} + +プロンプトから読み込んだ整数値に13を加えた値を表示するプログラム。 + +\subsection{コードリスティング} +\defaultlistingstyle +\lstinputlisting[language=C,title={演習1ー5}]{../programs/prog1/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/prog1.png} +\end{center} diff --git a/section/prog2.tex b/section/prog2.tex new file mode 100644 index 0000000..474d92b --- /dev/null +++ b/section/prog2.tex @@ -0,0 +1,13 @@ +\section{演習1ー6} + +プロンプトから読み込んだ整数値から7を減じた値を表示するプログラム。 + +\subsection{コードリスティング} +\defaultlistingstyle +\lstinputlisting[language=C,title={演習1ー6}]{../programs/prog2/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/prog2.png} +\end{center} diff --git a/section/syntax.tex b/section/syntax.tex new file mode 100644 index 0000000..0588cf6 --- /dev/null +++ b/section/syntax.tex @@ -0,0 +1,32 @@ +\section{今回の構文} + +\subsection{\texttt{scanf}関数} + +\texttt{scanf}関数は標準入力から文字列を読み取り、指定された書式に沿って解釈し、解釈結果の値を指定された場所に保存する。 +ここでいう場所とは変数のアドレスのことである。 +書式は\texttt{printf}関数と同じものである。\cite{cppref_scanf} + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={\texttt{scanf}関数}] +scanf("<書式>", <変数1へのアドレス>, <変数2へのアドレス>, ...); +\end{lstlisting} + +\begin{itembox}[l]{\textrm{コラム:標準入出力関数の戻り値}} + 標準入出力関数には\texttt{void}型を返す関数はほとんど定義されていない。 + + \vspace{0.25cm} + + \begin{center} + 表1:主な標準入出力関数の戻り値\cite{cppref_stdio} + + \vspace{0.125cm} + + \begin{tabular}{|ccl|} + \hline + 関数 & 型 & \multicolumn{1}{c|}{概要} \\ \hline \hline + \texttt{scanf}系 & \texttt{int} & 正常に読み込まれた変数の数、0または\texttt{EOF}定数はエラーとなる \\ \hline + \texttt{printf}系 & \texttt{int} & \vtop{\hbox{\strut バッファーやストリームに書き込まれた文字の数、}\hbox{\strut 負の値はエラーとなる}} \\ \hline + \vtop{\hbox{\strut \texttt{setbuf, rewind,}} \hbox{\strut \texttt{clearerr, perror}}} & \texttt{void} & \vtop{\hbox{\strut これらの関数のみ値を返さない、}\hbox{\strut エラーになり得る処理ではないから}} \\ \hline + \end{tabular} + \end{center} +\end{itembox}