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/p410.png b/assets/p410.png new file mode 100644 index 0000000..3c7f484 Binary files /dev/null and b/assets/p410.png differ diff --git a/assets/p411.png b/assets/p411.png new file mode 100644 index 0000000..9371396 Binary files /dev/null and b/assets/p411.png differ diff --git a/assets/p412.png b/assets/p412.png new file mode 100644 index 0000000..9475f8f Binary files /dev/null and b/assets/p412.png differ diff --git a/assets/p45.png b/assets/p45.png new file mode 100644 index 0000000..1640998 Binary files /dev/null and b/assets/p45.png differ diff --git a/assets/p46.png b/assets/p46.png new file mode 100644 index 0000000..26b2317 Binary files /dev/null and b/assets/p46.png differ diff --git a/assets/p47.png b/assets/p47.png new file mode 100644 index 0000000..779d50d Binary files /dev/null and b/assets/p47.png differ diff --git a/assets/p48.png b/assets/p48.png new file mode 100644 index 0000000..781a8fe Binary files /dev/null and b/assets/p48.png differ diff --git a/assets/p49.png b/assets/p49.png new file mode 100644 index 0000000..c035837 Binary files /dev/null and b/assets/p49.png differ diff --git a/document.yaml b/document.yaml index c49334c..5b873eb 100644 --- a/document.yaml +++ b/document.yaml @@ -1,28 +1,28 @@ doc_class: nitreport -title: Insert Title Here +title: 第13回課題 author: - name: 高専 太郎 - student_id: 0000-01 - seating_number: 1 + name: 柴田 健琉 + student_id: 2024D14 + seating_number: 15 date: year: 令和7年 - month: aa月 - day: bb日 + month: 07月 + day: 10日 turnin: year: 令和7年 - month: cc月 - day: dd日 + month: 07月 + day: 10日 -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,14 @@ 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: false } + - { path: 'section/p45', newpg: true } + - { path: 'section/p46', newpg: true } + - { path: 'section/p47', newpg: true } + - { path: 'section/p48', newpg: true } + - { path: 'section/p49', newpg: true } + - { path: 'section/p410', newpg: true } + - { path: 'section/p411', newpg: true } + - { path: 'section/p412', newpg: true } diff --git a/main.tex b/main.tex new file mode 100644 index 0000000..8d66727 --- /dev/null +++ b/main.tex @@ -0,0 +1,54 @@ +\documentclass{class/nitreport} + +\reporttitle{第13回課題} +\reportauthor{柴田 健琉} +\studentid{2024D14} +\seatingnum{15} +\reportdate{令和7年}{07月}{10日} +\turnindate{令和7年}{07月}{10日} +\schoolname{岐阜工業高等専門学校} +\department{電子制御工学科} +\subject{情報処理I} +\professor{岡崎 憲一} + +\pagenumbering{roman} + +\begin{document} + \coverpage + + \tableofcontents + \newpage + \pagenumbering{arabic} + + \input{section/introduction.tex} + + \input{section/syntax.tex} + + \input{section/p45} + \newpage + + \input{section/p46} + \newpage + + \input{section/p47} + \newpage + + \input{section/p48} + \newpage + + \input{section/p49} + \newpage + + \input{section/p410} + \newpage + + \input{section/p411} + \newpage + + \input{section/p412} + \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..7926dd8 Binary files /dev/null and b/output/main.pdf differ diff --git a/programs/p410/info.json b/programs/p410/info.json new file mode 100644 index 0000000..c4af3ad --- /dev/null +++ b/programs/p410/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-10", + "description": "入力した整数値の個数分縦にアスタリスクを表示するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p410.png" + }, + "note": "" +} diff --git a/programs/p410/main b/programs/p410/main new file mode 100755 index 0000000..da77b69 Binary files /dev/null and b/programs/p410/main differ diff --git a/programs/p410/main.c b/programs/p410/main.c new file mode 100644 index 0000000..77007c0 --- /dev/null +++ b/programs/p410/main.c @@ -0,0 +1,21 @@ +#include + +int main(void) { + int n; + + printf("Input positive integer: "); + scanf("%d", &n); + + if (n < 1) { + return 1; + } + + while (n-- > 0) { + putchar('*'); + if (n != 0) { + putchar('\n'); + } + } + + return 0; +} diff --git a/programs/p411/info.json b/programs/p411/info.json new file mode 100644 index 0000000..f6ed15c --- /dev/null +++ b/programs/p411/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-11", + "description": "教科書のList 4-10の出力に入力値も表示するように変更したプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p411.png" + }, + "note": "" +} diff --git a/programs/p411/main b/programs/p411/main new file mode 100755 index 0000000..4cf7361 Binary files /dev/null and b/programs/p411/main differ diff --git a/programs/p411/main.c b/programs/p411/main.c new file mode 100644 index 0000000..18f667b --- /dev/null +++ b/programs/p411/main.c @@ -0,0 +1,23 @@ +#include + +int main(void) { + int n; + + do { + printf("Input positive integer: "); + scanf("%d", &n); + if (n <= 0) { + puts("\aPlease input non-negative, non-zero integer."); + } + } while (n <= 0); + + printf("Reverse of %d is ", n); + while (n > 0) { + printf("%d", n % 10); + n /= 10; + } + + puts("."); + + return 0; +} diff --git a/programs/p412/info.json b/programs/p412/info.json new file mode 100644 index 0000000..9900a35 --- /dev/null +++ b/programs/p412/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-12", + "description": "入力した正の整数値の桁数を表示するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p412.png" + }, + "note": "" +} diff --git a/programs/p412/main b/programs/p412/main new file mode 100755 index 0000000..e264454 Binary files /dev/null and b/programs/p412/main differ diff --git a/programs/p412/main.c b/programs/p412/main.c new file mode 100644 index 0000000..219aa9f --- /dev/null +++ b/programs/p412/main.c @@ -0,0 +1,24 @@ +#include + +int main(void) { + int n; + + do { + printf("Input positive integer: "); + scanf("%d", &n); + if (n <= 0) { + puts("\aPlease input non-negative, non-zero integer."); + } + } while (n <= 0); + + int d = 0; + int x = n; + while (x > 0) { + x /= 10; + d++; + } + + printf("%d is %d digit number.\n", n, d); + + return 0; +} diff --git a/programs/p45/info.json b/programs/p45/info.json new file mode 100644 index 0000000..faa885c --- /dev/null +++ b/programs/p45/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-5", + "description": "教科書のList 4-7のスタートを0から1へ書き換えたプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p45.png" + }, + "note": "" +} diff --git a/programs/p45/main b/programs/p45/main new file mode 100755 index 0000000..ceed236 Binary files /dev/null and b/programs/p45/main differ diff --git a/programs/p45/main.c b/programs/p45/main.c new file mode 100644 index 0000000..aa1df82 --- /dev/null +++ b/programs/p45/main.c @@ -0,0 +1,21 @@ +#include + +int main(void) { + int n; + + printf("Input positive integer: "); + scanf("%d", &n); + + if (n <= 0) { + return 1; + } + + int i = 1; + + while (i <= n) { + printf("%d ", i++); + } + printf("\n"); + + return 0; +} diff --git a/programs/p46/info.json b/programs/p46/info.json new file mode 100644 index 0000000..2216765 --- /dev/null +++ b/programs/p46/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-6", + "description": "入力した整数値以下の偶数を出力するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p46.png" + }, + "note": "" +} diff --git a/programs/p46/main b/programs/p46/main new file mode 100755 index 0000000..aea7344 Binary files /dev/null and b/programs/p46/main differ diff --git a/programs/p46/main.c b/programs/p46/main.c new file mode 100644 index 0000000..981a4f1 --- /dev/null +++ b/programs/p46/main.c @@ -0,0 +1,22 @@ +#include + +int main(void) { + int n; + + printf("Input positive integer: "); + scanf("%d", &n); + + if (n <= 1) { + return 1; + } + + int i = 1; + + while (2*i <= n) { + printf("%d ", 2*i++); + } + + printf("\n"); + + return 0; +} diff --git a/programs/p47/info.json b/programs/p47/info.json new file mode 100644 index 0000000..0c2f425 --- /dev/null +++ b/programs/p47/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-7", + "description": "入力した整数値以下の2のべき乗を出力するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p47.png" + }, + "note": "" +} diff --git a/programs/p47/main b/programs/p47/main new file mode 100755 index 0000000..b1f5bd2 Binary files /dev/null and b/programs/p47/main differ diff --git a/programs/p47/main.c b/programs/p47/main.c new file mode 100644 index 0000000..e82109a --- /dev/null +++ b/programs/p47/main.c @@ -0,0 +1,23 @@ +#include + +int main(void) { + int n; + + printf("Input positive integer: "); + scanf("%d", &n); + + if (n <= 1) { + return 1; + } + + int i = 2; + + while (i <= n) { + printf("%d ", i); + i <<= 1; + } + + printf("\n"); + + return 0; +} diff --git a/programs/p48/info.json b/programs/p48/info.json new file mode 100644 index 0000000..acb93fc --- /dev/null +++ b/programs/p48/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-8", + "description": "教科書のList 4-8を1未満の時に改行を出力しないよにしたプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p48.png" + }, + "note": "" +} diff --git a/programs/p48/main b/programs/p48/main new file mode 100755 index 0000000..381e089 Binary files /dev/null and b/programs/p48/main differ diff --git a/programs/p48/main.c b/programs/p48/main.c new file mode 100644 index 0000000..d76b098 --- /dev/null +++ b/programs/p48/main.c @@ -0,0 +1,20 @@ +#include + +int main(void) { + int n; + + printf("Input positive integer: "); + scanf("%d", &n); + + if (n < 1) { + return 1; + } + + while (n-- > 0) { + putchar('*'); + } + + putchar('\n'); + + return 0; +} diff --git a/programs/p49/info.json b/programs/p49/info.json new file mode 100644 index 0000000..851d31a --- /dev/null +++ b/programs/p49/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 4-9", + "description": "入力した整数値の個数分$+$と$-$を交互に出力するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p49.png" + }, + "note": "" +} diff --git a/programs/p49/main b/programs/p49/main new file mode 100755 index 0000000..8e2672b Binary files /dev/null and b/programs/p49/main differ diff --git a/programs/p49/main.c b/programs/p49/main.c new file mode 100644 index 0000000..5b158b3 --- /dev/null +++ b/programs/p49/main.c @@ -0,0 +1,27 @@ +#include + +int main(void) { + int n; + + printf("Input positive integer: "); + scanf("%d", &n); + + if (n <= 0) { + return 1; + } + + int i = 0; + + while (i < n) { + if (i % 2) { + putchar('-'); + } else { + putchar('+'); + } + i++; + } + + putchar('\n'); + + return 0; +} diff --git a/references.bib b/references.bib index bc328a4..89a9680 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, + title = {putchar}, + author = {cppreference}, + url = {https://en.cppreference.com/w/c/io/putchar}, + urldate = {2025-07-10} } 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/p410.tex b/section/p410.tex new file mode 100644 index 0000000..713ade7 --- /dev/null +++ b/section/p410.tex @@ -0,0 +1,13 @@ +\section{演習 4-10} + +入力した整数値の個数分縦にアスタリスクを表示するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-10}]{../programs/p410/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p410.png} +\end{center} diff --git a/section/p411.tex b/section/p411.tex new file mode 100644 index 0000000..a68fa5d --- /dev/null +++ b/section/p411.tex @@ -0,0 +1,13 @@ +\section{演習 4-11} + +教科書のList 4-10の出力に入力値も表示するように変更したプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-11}]{../programs/p411/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p411.png} +\end{center} diff --git a/section/p412.tex b/section/p412.tex new file mode 100644 index 0000000..6c1afb0 --- /dev/null +++ b/section/p412.tex @@ -0,0 +1,13 @@ +\section{演習 4-12} + +入力した正の整数値の桁数を表示するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-12}]{../programs/p412/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p412.png} +\end{center} diff --git a/section/p45.tex b/section/p45.tex new file mode 100644 index 0000000..8d7a63f --- /dev/null +++ b/section/p45.tex @@ -0,0 +1,13 @@ +\section{演習 4-5} + +教科書のList 4-7のスタートを0から1へ書き換えたプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-5}]{../programs/p45/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p45.png} +\end{center} diff --git a/section/p46.tex b/section/p46.tex new file mode 100644 index 0000000..bd4f682 --- /dev/null +++ b/section/p46.tex @@ -0,0 +1,13 @@ +\section{演習 4-6} + +入力した整数値以下の偶数を出力するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-6}]{../programs/p46/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p46.png} +\end{center} diff --git a/section/p47.tex b/section/p47.tex new file mode 100644 index 0000000..ac750e6 --- /dev/null +++ b/section/p47.tex @@ -0,0 +1,13 @@ +\section{演習 4-7} + +入力した整数値以下の2のべき乗を出力するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-7}]{../programs/p47/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p47.png} +\end{center} diff --git a/section/p48.tex b/section/p48.tex new file mode 100644 index 0000000..eb3c9f4 --- /dev/null +++ b/section/p48.tex @@ -0,0 +1,13 @@ +\section{演習 4-8} + +教科書のList 4-8を1未満の時に改行を出力しないよにしたプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-8}]{../programs/p48/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p48.png} +\end{center} diff --git a/section/p49.tex b/section/p49.tex new file mode 100644 index 0000000..05526f4 --- /dev/null +++ b/section/p49.tex @@ -0,0 +1,13 @@ +\section{演習 4-9} + +入力した整数値の個数分$+$と$-$を交互に出力するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習 4-9}]{../programs/p49/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/p49.png} +\end{center} diff --git a/section/syntax.tex b/section/syntax.tex new file mode 100644 index 0000000..d6c8318 --- /dev/null +++ b/section/syntax.tex @@ -0,0 +1,34 @@ +\section{今回の構文} + +\subsection{\texttt{putchar}関数} + +\texttt{putchar}関数は標準出力に引数で渡した文字(または整数表現の文字コード)を書き込む関数である。 +引数は関数内部で\texttt{unsigned char}型に変換される。\cite{cppref} + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={\texttt{putchar}関数}] +putchar('a'); // "a" が出力される +\end{lstlisting} + +\subsection{\texttt{break}・\texttt{continue}文} + +\texttt{break}・\texttt{continue}文はループ内で処理を中断・スキップする処理を記述する文である。 +\texttt{goto}文ともに、濫用するとコードが読みにくくなるので注意が必要である。 + +\defaultlistingstyle +\begin{lstlisting}[language=C,title={\texttt{break}・\texttt{continue}文}] +int i = 0; +while (i < 10) { + if (i % 3) { + continue; + } + + if (i == 8) { + break; + } + + printf("%d ", i++); +} + +// 出力:0 1 2 4 5 7 +\end{lstlisting}