diff --git a/programs/p310/info.json b/programs/p310/info.json new file mode 100644 index 0000000..e36a59a --- /dev/null +++ b/programs/p310/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 3-10", + "description": "3つの整数値の等価検証プログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p310.png" + }, + "note": "" +} diff --git a/programs/p310/main b/programs/p310/main new file mode 100755 index 0000000..01c065b Binary files /dev/null and b/programs/p310/main differ diff --git a/programs/p310/main.c b/programs/p310/main.c new file mode 100644 index 0000000..39b8e3e --- /dev/null +++ b/programs/p310/main.c @@ -0,0 +1,69 @@ +#include + +#define NON_EQUAL 0 +#define ONE_EQUAL 1 +#define ALL_EQUAL 2 + +#ifndef USE_ALT + +int main(void) { + int a, b, c; + + printf("Int A: "); + scanf("%d", &a); + printf("Int B: "); + scanf("%d", &b); + printf("Int C: "); + scanf("%d", &c); + + if (a == b && a == c) { + printf("All three values are equal.\n"); + } else if (a != b && a == c) { + printf("Two values are equal.\n"); + } else if (a != c && a == b) { + printf("Two values are equal.\n"); + } else if (b == c) { + printf("Two values are equal.\n"); + } else { + printf("All three values are different.\n"); + } + + return 0; +} + +#endif // !(defined(USE_ALT)) + +#ifdef USE_ALT + +// alternetive answer +int main(void) { + int flag = 0; // remember, boolean in C is just integer + + int a, b, c; + + printf("Int A: "); + scanf("%d", &a); + printf("Int B: "); + scanf("%d", &b); + printf("Int C: "); + scanf("%d", &c); + + flag += a == b; + flag += a == c; + + if (flag != ALL_EQUAL) { + flag += b == c; + } + + if (flag == NON_EQUAL) { + printf("All three values are different.\n"); + } else if (flag == ONE_EQUAL) { + printf("Two values are equal.\n"); + } else { + printf("All three values are equal.\n"); + } + + return 0; +} + +#endif // defined(USE_ALT) diff --git a/programs/p311/info.json b/programs/p311/info.json new file mode 100644 index 0000000..9889715 --- /dev/null +++ b/programs/p311/info.json @@ -0,0 +1,10 @@ +{ + "language": "C", + "name": "演習 3-11", + "description": "論理OR演算子を使用して2つの整数値の差が10以下であるか、11以上であるかを検証するプログラム。", + "output": { + "type": "screenshot", + "content": "./assets/p311.png" + }, + "note": "" +} diff --git a/programs/p311/main b/programs/p311/main new file mode 100755 index 0000000..58a4a8f Binary files /dev/null and b/programs/p311/main differ diff --git a/programs/p311/main.c b/programs/p311/main.c new file mode 100644 index 0000000..4dbedd8 --- /dev/null +++ b/programs/p311/main.c @@ -0,0 +1,20 @@ +#include + +int main(void) { + int a, b; + + printf("Int A: "); + scanf("%d", &a); + printf("Int B: "); + scanf("%d", &b); + + int diff = a - b; + + if (diff >= 11 || diff <= -11) { + printf("Difference is greater than or equal to 11.\n"); + } else { + printf("Difference is less than or equal to 10.\n"); + } + + return 0; +} diff --git a/section/introduction.tex b/section/introduction.tex index 3386076..ff9cc1c 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: NixOS 25.05 (Warbler) + \item CPU アーキテクチャ: \texttt{x86\_64} + \item C コンパイラ: \texttt{gcc バージョン 14.2.1 20250322 (GCC)} + \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