diff --git a/assets/prog3.png b/assets/prog3.png new file mode 100644 index 0000000..4098fbd Binary files /dev/null and b/assets/prog3.png differ diff --git a/assets/prog4.png b/assets/prog4.png new file mode 100644 index 0000000..2736528 Binary files /dev/null and b/assets/prog4.png differ diff --git a/assets/prog5.png b/assets/prog5.png new file mode 100644 index 0000000..d6f4dff Binary files /dev/null and b/assets/prog5.png differ diff --git a/document.yaml b/document.yaml index 965059a..fa159f4 100644 --- a/document.yaml +++ b/document.yaml @@ -25,4 +25,7 @@ sections: - { path: 'section/syntax.tex', newpg: true } - { path: 'section/prog1.tex', newpg: true } - { path: 'section/prog2.tex', newpg: true } + - { path: 'section/prog3.tex', newpg: true } + - { path: 'section/prog4.tex', newpg: true } + - { path: 'section/prog5.tex', newpg: true } - { path: 'section/appendix.tex', newpg: true } diff --git a/main.tex b/main.tex index e27a39c..c7df75e 100644 --- a/main.tex +++ b/main.tex @@ -31,6 +31,15 @@ \input{section/prog2.tex} \newpage + \input{section/prog3.tex} + \newpage + + \input{section/prog4.tex} + \newpage + + \input{section/prog5.tex} + \newpage + \input{section/appendix.tex} \newpage diff --git a/output/main-opt-final.pdf b/output/main-opt-final.pdf index d3fa9c3..b73f33d 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 e8bf857..e157afd 100644 Binary files a/output/main.pdf and b/output/main.pdf differ diff --git a/programs/prog3/info.json b/programs/prog3/info.json new file mode 100644 index 0000000..14379c2 --- /dev/null +++ b/programs/prog3/info.json @@ -0,0 +1,9 @@ +{ + "name": "演習1ー8", + "description": "プロンプトから読み込んだ2つの整数値の積を表示するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/prog3.png" + }, + "note": "" +} diff --git a/programs/prog3/main b/programs/prog3/main new file mode 100755 index 0000000..d477c7a Binary files /dev/null and b/programs/prog3/main differ diff --git a/programs/prog3/main.c b/programs/prog3/main.c new file mode 100644 index 0000000..a872a68 --- /dev/null +++ b/programs/prog3/main.c @@ -0,0 +1,16 @@ +#include + +int main(void) { + int n1; + int n2; + + printf("Input two integers.\n"); + printf("Integer n1: "); + scanf("%d", &n1); + printf("Integer n2: "); + scanf("%d", &n2); + + printf("The product of two integers is %d.", n1 * n2); + + return 0; +} diff --git a/programs/prog4/info.json b/programs/prog4/info.json new file mode 100644 index 0000000..6e2a7d5 --- /dev/null +++ b/programs/prog4/info.json @@ -0,0 +1,9 @@ +{ + "name": "演習1ー9", + "description": "プロンプトから読み込んだ3つの整数値の和を表示するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/prog4.png" + }, + "note": "" +} diff --git a/programs/prog4/main b/programs/prog4/main new file mode 100755 index 0000000..fa460f5 Binary files /dev/null and b/programs/prog4/main differ diff --git a/programs/prog4/main.c b/programs/prog4/main.c new file mode 100644 index 0000000..a6890b8 --- /dev/null +++ b/programs/prog4/main.c @@ -0,0 +1,19 @@ +#include + +int main(void) { + int n1; + int n2; + int n3; + + printf("Input three integers.\n"); + printf("Integer n1: "); + scanf("%d", &n1); + printf("Integer n2: "); + scanf("%d", &n2); + printf("Integer n3: "); + scanf("%d", &n3); + + printf("The sum of three integers is %d.", n1 + n2 + n3); + + return 0; +} diff --git a/programs/prog5/info.json b/programs/prog5/info.json new file mode 100644 index 0000000..d33dc50 --- /dev/null +++ b/programs/prog5/info.json @@ -0,0 +1,9 @@ +{ + "name": "考察:List 1-11", + "description": "List 1-11 にて、入力に3.14や0.5などの小数を入力すると出力はどうなるか。", + "output": { + "type": "screenshot", + "content": "./assets/prog5.png" + }, + "note": "入力した全ての小数が繰り下げられている。\\\\texttt{\\%d}は整数しか表示できず、小数の場合は小数部を切り捨て、整数部のみ表示している。" +} diff --git a/programs/prog5/main b/programs/prog5/main new file mode 100755 index 0000000..a6f7b07 Binary files /dev/null and b/programs/prog5/main differ diff --git a/programs/prog5/main.c b/programs/prog5/main.c new file mode 100644 index 0000000..f151e54 --- /dev/null +++ b/programs/prog5/main.c @@ -0,0 +1,12 @@ +#include + +int main(void) { + int no; + + printf("Input an integer: "); + scanf("%d", &no); + + printf("You inputed %d.\n", no); + + return 0; +} diff --git a/script/info-proc-programs.bash b/script/info-proc-programs.bash index 8d4a59e..f16834c 100644 --- a/script/info-proc-programs.bash +++ b/script/info-proc-programs.bash @@ -64,7 +64,7 @@ function writeSection () { x=$(($x+1)) done - res+="\n\\section{実行結果}\n" + res+="\n\\subsection{実行結果}\n" if [[ $outType == "screenshot" ]]; then res+="\n\\\\begin{center}\n \\includegraphics[width=\\\\textwidth]{$outContent}\n\\\\end{center}" diff --git a/section/prog3.tex b/section/prog3.tex new file mode 100644 index 0000000..b86e4c1 --- /dev/null +++ b/section/prog3.tex @@ -0,0 +1,13 @@ +\section{演習1ー8} + +プロンプトから読み込んだ2つの整数値の積を表示するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習1ー8}]{../programs/prog3/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/prog3.png} +\end{center} diff --git a/section/prog4.tex b/section/prog4.tex new file mode 100644 index 0000000..a2f668b --- /dev/null +++ b/section/prog4.tex @@ -0,0 +1,13 @@ +\section{演習1ー9} + +プロンプトから読み込んだ3つの整数値の和を表示するプログラム。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={演習1ー9}]{../programs/prog4/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/prog4.png} +\end{center} diff --git a/section/prog5.tex b/section/prog5.tex new file mode 100644 index 0000000..e185ca2 --- /dev/null +++ b/section/prog5.tex @@ -0,0 +1,19 @@ +\section{考察:List 1-11} + +List 1-11 にて、入力に3.14や0.5などの小数を入力すると出力はどうなるか。 + +\subsection{コードリスティング} + +\lstinputlisting[language=C,title={考察:List 1-11}]{../programs/prog5/main.c} + +\subsection{実行結果} + +\begin{center} + \includegraphics[width=\textwidth]{./assets/prog5.png} +\end{center} + +\subsection{考察} + +入力した全ての小数が繰り下げられている。 +\texttt{\%d}は整数しか表示できず、小数の場合は小数部を切り捨て、整数部のみ表示している。 +小数を表示したい場合は\texttt{printf}関数と\texttt{scanf}関数両方の書式を\texttt{\%f}にする必要がある。