This commit is contained in:
2026-04-21 09:43:01 +09:00
parent e8c1f49f70
commit a7200482d8
12 changed files with 364 additions and 1 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

+29
View File
@@ -0,0 +1,29 @@
\subsection{開発環境}
\subsubsection{OS}
筆者の開発環境ではNixOSというNixパッケージマネージャーを用いたLinuxベースの\texttt{x86\_64}OSを使用している. 執筆時点でのOSバージョンは\texttt{25.11 (Xantusia)}で, Linuxカーネルバージョンは\texttt{6.19.12}である.
\subsubsection{開発パッケージ}
筆者の開発環境はNixという専用の関数型言語Nixで記述された宣言的で再現可能なUnix系OS用のパッケージマネージャーを使用して構築されている.
このパッケージマネージャーを用いて以下のパッケージを導入した:
\begin{itemize}
\item \texttt{gcc15} - GNU Compiler Collection Version 15
\item \texttt{gdb} - GNU Debugger
\item \texttt{gnumake} - GNU Make
\item \texttt{gf} - GDB Frontend 2
\item \texttt{clang-tools} - Clangに付属するツール郡のスタンドアローンパッケージ
\end{itemize}
執筆時点で使用したパッケージレポジトリ\texttt{nixpkgs/nixos-unstable}のハッシュは\texttt{sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=}である.
\subsubsection{環境記述ファイル - \texttt{flake.nix}}
開発環境は\LaTeX{}の執筆環境と共に\texttt{flake.nix}にて宣言・定義されている.
開発に用いられる一時シェルの宣言箇所を以下に記す:
\lstinputlisting[consecutivenumbers=false,linerange={195-207},title={開発環境の一時シェル}]{./flake.nix}
+15 -1
View File
@@ -23,6 +23,7 @@
vim-eskk = prev.vimUtils.buildVimPlugin {
name = "vim-eskk";
src = eskk-vim;
buildInputs = [ pkgs.skkDictionaries.l ];
};
};
})
@@ -63,7 +64,7 @@
let g:eskk#directory = "~/.config/eskk"
let g:eskk#dictionary = { 'path': "~/.config/eskk/jisyo", 'sorted': 1, 'encoding': 'utf-8', }
let g:eskk#large_dictionary = { 'path': "~/.config/eskk/SKK-JISYO.L", 'sorted': 1, 'encoding': 'euc-jp', }
let g:eskk#large_dictionary = { 'path': "${pkgs.skkDictionaries.l}/share/skk/SKK-JISYO.L", 'sorted': 1, 'encoding': 'euc-jp', }
let g:eskk#kakutei_when_unique_candidate = 0
let g:eskk#enable_completion = 0
let g:eskk#no_default_mappings = 1
@@ -191,6 +192,19 @@
pkgs.qpdfview
];
};
devShells.cc = pkgs.stdenv.mkDerivation {
inherit name;
shellHook = ''
export PS1="${name} cc \w \$ "
'';
buildInputs = with pkgs; [
gcc15
gdb
gf
gnumake
clang-tools
];
};
}
);
}
Binary file not shown.
Binary file not shown.
+80
View File
@@ -0,0 +1,80 @@
\documentclass[xelatex,a4paper,11pt,ja=standard]{bxjsarticle}
\usepackage{tex/preamble}
\usepackage{tex/detailed-title}
\usepackage{multirow}
\reportauthor{柴田健琉}
\reporttitle{前期第2回課題}
\reportdate{2026年}{04月}{20日}
\turnindate{2026年}{04月}{21日}
\schoolname{岐阜工業高等専門学校}
\department{電子制御工学科}
\subject{情報処理2}
\professor{遠藤 登}
\studentid{2024D14}
\seatingnum{15}
\begin{document}
\detailedtitle
\section{はじめに}
この課題のプログラムは以下の環境での実行が確認されている:
\begin{itemize}
\item{OS: NixOS 25.11, Linux 6.19.12}
\item{GCC: 15.2.0}
\item{コンパイラフラグ: \texttt{-g -O1 -Wall -Wpedantic}}
\end{itemize}
\section{下準備:並び換えるデータの用意}
課題に使用するデータはLinuxの\texttt{/dev/urandom}で以下のbashコマンドで生成した.
\begin{lstlisting}[language=bash,title={乱数配列生成コマンド(Xに任意の個数)}]
$ sed '1i\#pragma once\' <(head -c X /dev/urandom | xxd -iC -n dataX) > dataX.h
\end{lstlisting}
出力されるヘッダーファイルには\texttt{unsigned char}型の乱数配列\texttt{dataX}と配列の長さ\texttt{dataX\_len}が格納されている.
\lstinputlisting[language=C,title={\texttt{data10.h}}]{src/cls02/data10.h}
\lstinputlisting[language=C,title={\texttt{data100.h}},linerange={1-3,11-13},consecutivenumbers={false}]{src/cls02/data100.h}
\lstinputlisting[language=C,title={\texttt{data1000.h}},linerange={1-3,86-88},consecutivenumbers={false}]{src/cls02/data1000.h}
\newpage
\section{課題:3つのソートアルゴリズム}
10個, 100個, 1000個の乱数データに対し, 単純交換・単純選択・単純挿入ソートを実行し, 交換回数・比較回数を記録する.
\lstinputlisting[language=C,title={3つのソートアルゴリズム}]{src/cls02/main.c}
\subsection{実行結果}
\begin{figure}[tbh]
\centering
\includegraphics[width=12cm]{assets/cls02.png}
\caption{実行結果}
\end{figure}
\begin{table}[!ht]
\centering
\begin{tabular}{c|c|c|c|c|c|c}
\hline
\multirow{2}{6em}{データ数} & \multicolumn{2}{|c|}{単純交換} & \multicolumn{2}{|c|}{単純選択} & \multicolumn{2}{c}{単純挿入} \\
\cline{2-7}
& 比較 & 交換 & 比較 & 交換 & 比較 & 交換 \\
\hline
10 & 81 & 20 & 55 & 10 & 45 & 20 \\
100 & 9801 & 2571 & 5050 & 100 & 4950 & 2205 \\
1000 & 998001 & 243054 & 500500 & 1000 & 499500 & 94085 \\
\hline
\end{tabular}
\caption{ソートアルゴリズムとデータ数での比較・交換回数}
\end{table}
\appendix
\section{付録}
\input{dev-env.tex}
\end{document}
+14
View File
@@ -0,0 +1,14 @@
include ../common.mk
PROJECT_NAME:=cls02
TGTS:=$(patsubst %.c,%,$(wildcard *.c))
all: $(TGTS)
%: %.c
@mkdir -p $(BUILD_PATH)/$(PROJECT_NAME)
$(CC) $(CFLAGS) -I. $^ -o $(BUILD_PATH)/$(PROJECT_NAME)/$@
clean:
$(RM) -drf $(BUILD_PATH)/$(PROJECT_NAME)
+5
View File
@@ -0,0 +1,5 @@
#pragma once
unsigned char data10[] = {
0x4c, 0xa7, 0x72, 0x27, 0x5f, 0x7a, 0x49, 0x2e, 0xd2, 0x98
};
unsigned int data10_len = 10;
+13
View File
@@ -0,0 +1,13 @@
#pragma once
unsigned char data100[] = {
0xf2, 0xfa, 0xfe, 0x5c, 0xab, 0x2c, 0x5c, 0x26, 0x9d, 0x54, 0x12, 0x56,
0xcd, 0x70, 0xb1, 0x0e, 0x34, 0x97, 0x70, 0x79, 0x42, 0xc8, 0xc6, 0x08,
0xf7, 0x3f, 0x52, 0xf8, 0x8d, 0xb9, 0x61, 0x75, 0xd4, 0xf2, 0xdd, 0x91,
0x69, 0xa3, 0xee, 0xa2, 0xd2, 0xd7, 0x98, 0x2f, 0x8e, 0x76, 0x74, 0x5b,
0x7a, 0xb6, 0x22, 0x3e, 0xd2, 0x2b, 0xc8, 0xf4, 0xed, 0xa3, 0x5b, 0xb1,
0xc8, 0xd5, 0x02, 0x57, 0x10, 0x80, 0xe0, 0xd8, 0xcd, 0x93, 0xd3, 0xef,
0x6b, 0x1d, 0x24, 0xc7, 0x05, 0xf0, 0x17, 0xae, 0xd8, 0x76, 0x34, 0x9d,
0x14, 0xe2, 0x59, 0x0b, 0x8e, 0xc4, 0x2a, 0x2b, 0xba, 0xdb, 0x07, 0xa2,
0xbf, 0x52, 0x42, 0x8c
};
unsigned int data100_len = 100;
+88
View File
@@ -0,0 +1,88 @@
#pragma once
unsigned char data1000[] = {
0x1a, 0x59, 0xcf, 0xee, 0xf0, 0x16, 0x17, 0x4e, 0x3e, 0xa0, 0x24, 0x97,
0x0a, 0x7a, 0xd4, 0x2f, 0x78, 0x59, 0x2e, 0x7e, 0xa0, 0x38, 0x76, 0x63,
0x2a, 0x81, 0xb3, 0x6f, 0xe4, 0xc6, 0x33, 0xfe, 0xae, 0xd2, 0xfc, 0x28,
0xb5, 0x57, 0xac, 0x3b, 0x6e, 0x14, 0xe2, 0x7f, 0x1d, 0x2d, 0xe7, 0x63,
0x28, 0xfb, 0x4f, 0x74, 0x3d, 0x59, 0xd3, 0x65, 0x1b, 0xb8, 0x7d, 0x3a,
0x9b, 0x56, 0xe1, 0x40, 0x85, 0x1c, 0x42, 0x8c, 0xdf, 0x65, 0x75, 0xf7,
0x99, 0xe9, 0x42, 0xbd, 0x3a, 0x18, 0xf8, 0xdc, 0x47, 0x4f, 0x42, 0x33,
0x64, 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, 0x00, 0x0b, 0x43, 0x23, 0x6a, 0xe3, 0xf6,
0x16, 0x71, 0x80, 0xb8, 0x15, 0x88, 0x21, 0xc3, 0x92, 0x05, 0xb9, 0x14,
0x3c, 0xd1, 0xbc, 0x23, 0x5c, 0xb2, 0xf9, 0x6f, 0x6a, 0x0a, 0x93, 0x48,
0x85, 0xc6, 0x4b, 0x59, 0x31, 0x16, 0x94, 0x72, 0x29, 0x48, 0x5f, 0xd3,
0xcb, 0x98, 0x0f, 0x1f, 0x6d, 0x82, 0xb5, 0x71, 0x72, 0x90, 0xdd, 0x57,
0x82, 0x4e, 0x41, 0x40, 0x6c, 0xfa, 0xe7, 0x44, 0x4a, 0x09, 0x74, 0x67,
0xa8, 0xeb, 0xcf, 0x35, 0x75, 0xd0, 0xca, 0x68, 0x15, 0x05, 0x93, 0x87,
0xc0, 0xfe, 0x03, 0xb9, 0xe7, 0x5b, 0x72, 0x7e, 0x1b, 0x7d, 0x50, 0x55,
0x06, 0x28, 0x5a, 0xd0, 0xca, 0xc5, 0xcf, 0x62, 0x52, 0xf5, 0x2e, 0x38,
0xda, 0xe6, 0xc4, 0xd9, 0x8d, 0xfb, 0xdd, 0xa4, 0x5a, 0xcb, 0xa4, 0xb2,
0xac, 0xdd, 0x02, 0xbd, 0xe6, 0xc8, 0xa9, 0xd4, 0x28, 0x7e, 0xf6, 0xaa,
0x41, 0x50, 0x2b, 0x08, 0x55, 0x1d, 0x4b, 0xa8, 0xbb, 0x97, 0x62, 0xf9,
0xd4, 0xc8, 0x50, 0x44, 0x44, 0xb6, 0x17, 0x99, 0x57, 0x8c, 0x23, 0x86,
0xfd, 0xe6, 0xf1, 0xcd, 0xd8, 0x43, 0x8c, 0x4f, 0xec, 0xe6, 0xfc, 0x30,
0xca, 0x43, 0xbf, 0xc8, 0xae, 0xe7, 0x1c, 0x6e, 0x19, 0x59, 0x81, 0xb2,
0xca, 0x30, 0x3e, 0x31
};
unsigned int data1000_len = 1000;
+109
View File
@@ -0,0 +1,109 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "data10.h"
#include "data100.h"
#include "data1000.h"
// struct to store swaps and comps during sorting
typedef struct {
size_t swaps;
size_t comparisions;
} Status;
// Common Sorting Algorithim Function Signiture/Pointer
typedef void (*SortAlg)(unsigned char *, size_t, Status *);
// print first <head> and last <tail> elements of <arr>
void printArr(unsigned char *arr, size_t len, size_t head, size_t tail) {
for (size_t i = 0; i < len; i++) {
if (i >= len - tail || i < head) {
printf("%d ", arr[i]);
} else {
if (i % 50 == 0)
printf(". ");
}
}
putchar('\n');
}
// swap values
void swap(unsigned char *a, unsigned char *b) {
unsigned char t = *a;
*a = *b;
*b = t;
}
void bubble_sort(unsigned char *arr, size_t len, Status *stat) {
for (size_t i = 0; i < len - 1; i++) {
for (size_t j = 0; j < len - 1; j++) {
if (arr[j] > arr[j + 1]) {
swap(&arr[j], &arr[j + 1]);
stat->swaps++;
}
stat->comparisions++;
}
}
}
void selection_sort(unsigned char *arr, size_t len, Status *stat) {
for (size_t i = 0; i < len; i++) {
size_t min_idx = i;
for (size_t j = i; j < len; j++) {
if (arr[j] < arr[min_idx]) {
min_idx = j;
}
stat->comparisions++;
}
swap(&arr[i], &arr[min_idx]);
stat->swaps++;
}
}
void insertion_sort(unsigned char *arr, size_t len, Status *stat) {
for (size_t i = 1; i < len; i++) {
for (size_t j = 0; j < i; j++) {
if (arr[j] > arr[i]) {
swap(&arr[j], &arr[i]);
stat->swaps++;
}
stat->comparisions++;
}
}
}
int main(void) {
unsigned char *datasets[3] = {data10, data100, data1000};
size_t datasetLengths[3] = {data10_len, data100_len, data1000_len};
char *labels[3] = {"bubble", "selection", "insertion"};
SortAlg algs[3] = {bubble_sort, selection_sort, insertion_sort};
unsigned char *buffer =
(unsigned char *)(malloc(sizeof(unsigned char) * 1000));
Status stats[3][3] = {{{0}}};
// For each 3 datasets, perform 3 different sorting algorithims on copied
// array
for (size_t n = 0; n < 3; n++) {
for (size_t m = 0; m < 3; m++) {
printf("%s #%ld\n", labels[m], n + 1);
memcpy(buffer, datasets[n], datasetLengths[n]);
printf("Before: ");
printArr(buffer, datasetLengths[n], 10, 10);
(*algs[m])(buffer, datasetLengths[n], &stats[n][m]);
printf("After: ");
printArr(buffer, datasetLengths[n], 10, 10);
}
putchar('\n');
}
for (size_t i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
printf("%s %ld: swaps: %ld, comps: %ld\n", labels[j],
datasetLengths[i], stats[i][j].swaps,
stats[i][j].comparisions);
}
}
return 0;
}
+11
View File
@@ -0,0 +1,11 @@
CC:=gcc
CFLAGS:=-g -O1 -Wall -Wpedantic
CXX:=g++
CXXFLAGS:=-g -O1 -Wall -Wpedantic
RM:=rm
DEBUGGER:=gf2
#DEBUGGER:=gdb
BUILD_PATH:=$(abspath ../build)