added programs

This commit is contained in:
2025-04-30 01:50:13 +09:00
parent 6acb05157f
commit 88519283e1
20 changed files with 132 additions and 1 deletions

BIN
assets/prog3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
assets/prog4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
assets/prog5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -25,4 +25,7 @@ sections:
- { path: 'section/syntax.tex', newpg: true } - { path: 'section/syntax.tex', newpg: true }
- { path: 'section/prog1.tex', newpg: true } - { path: 'section/prog1.tex', newpg: true }
- { path: 'section/prog2.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 } - { path: 'section/appendix.tex', newpg: true }

View File

@@ -31,6 +31,15 @@
\input{section/prog2.tex} \input{section/prog2.tex}
\newpage \newpage
\input{section/prog3.tex}
\newpage
\input{section/prog4.tex}
\newpage
\input{section/prog5.tex}
\newpage
\input{section/appendix.tex} \input{section/appendix.tex}
\newpage \newpage

Binary file not shown.

Binary file not shown.

9
programs/prog3/info.json Normal file
View File

@@ -0,0 +1,9 @@
{
"name": "演習1ー8",
"description": "プロンプトから読み込んだ2つの整数値の積を表示するプログラム。",
"output": {
"type": "screenshot",
"content": "./assets/prog3.png"
},
"note": ""
}

BIN
programs/prog3/main Executable file

Binary file not shown.

16
programs/prog3/main.c Normal file
View File

@@ -0,0 +1,16 @@
#include <stdio.h>
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;
}

9
programs/prog4/info.json Normal file
View File

@@ -0,0 +1,9 @@
{
"name": "演習1ー9",
"description": "プロンプトから読み込んだ3つの整数値の和を表示するプログラム。",
"output": {
"type": "screenshot",
"content": "./assets/prog4.png"
},
"note": ""
}

BIN
programs/prog4/main Executable file

Binary file not shown.

19
programs/prog4/main.c Normal file
View File

@@ -0,0 +1,19 @@
#include <stdio.h>
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;
}

9
programs/prog5/info.json Normal file
View File

@@ -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}は整数しか表示できず、小数の場合は小数部を切り捨て、整数部のみ表示している。"
}

BIN
programs/prog5/main Executable file

Binary file not shown.

12
programs/prog5/main.c Normal file
View File

@@ -0,0 +1,12 @@
#include <stdio.h>
int main(void) {
int no;
printf("Input an integer: ");
scanf("%d", &no);
printf("You inputed %d.\n", no);
return 0;
}

View File

@@ -64,7 +64,7 @@ function writeSection () {
x=$(($x+1)) x=$(($x+1))
done done
res+="\n\\section{実行結果}\n" res+="\n\\subsection{実行結果}\n"
if [[ $outType == "screenshot" ]]; then if [[ $outType == "screenshot" ]]; then
res+="\n\\\\begin{center}\n \\includegraphics[width=\\\\textwidth]{$outContent}\n\\\\end{center}" res+="\n\\\\begin{center}\n \\includegraphics[width=\\\\textwidth]{$outContent}\n\\\\end{center}"

13
section/prog3.tex Normal file
View File

@@ -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}

13
section/prog4.tex Normal file
View File

@@ -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}

19
section/prog5.tex Normal file
View File

@@ -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}にする必要がある。