initial commit / finished report

This commit is contained in:
kenryuS committed 2026-10-12 12:01:52 +09:00
commit 90a915fcf0
12 files changed
+318

No files matched your search

+1
View File
@@ -0,0 +1 @@
.intermediates/
+6
View File
@@ -0,0 +1,6 @@
$out_dir = "./out";
$emulate_aux = 1;
$aux_dir = ".intermediates";
$pdf_mode = 5;
$xelatex = "xelatex -synctex=1 -file-line-error -interaction-nonstopmode %O %S";
+2
View File
@@ -0,0 +1,2 @@
# Info proc Q3 1st assignment
Generated
+147
View File
@@ -0,0 +1,147 @@
{
"nodes": {
"eskk-vim": {
"flake": false,
"locked": {
"lastModified": 1778495889,
"narHash": "sha256-1R/ChmsdtSXMEMMtKuyXgX7oe7ZE0a8gdx3sC9s6wp0=",
"owner": "vim-skk",
"repo": "eskk.vim",
"rev": "131a290d5305b9bf06426cfe32065f97e23d471c",
"type": "github"
},
"original": {
"owner": "vim-skk",
"repo": "eskk.vim",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1791048980,
"narHash": "sha256-KgItSKML8Xvte0B7/uGnBDsYzSnnKHcOaiUbgWBXLXw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a7868a727837f3c09cee2ce0ca671c76b1589fed",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1791048980,
"narHash": "sha256-KgItSKML8Xvte0B7/uGnBDsYzSnnKHcOaiUbgWBXLXw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a7868a727837f3c09cee2ce0ca671c76b1589fed",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"report-temp": {
"inputs": {
"eskk-vim": "eskk-vim",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1791173037,
"narHash": "sha256-FNA6OiLdj0Gb1755NWjEnWeNfsRZd1QGorhwl6BtgMo=",
"owner": "kenryuS",
"repo": "report-temp",
"rev": "5275b93bc3f6fade70a1ec11689f45bdf2a77169",
"type": "github"
},
"original": {
"owner": "kenryuS",
"repo": "report-temp",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"report-temp": "report-temp"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+23
View File
@@ -0,0 +1,23 @@
{
description = "Template for LaTeX";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
report-temp.url = "github:kenryuS/report-temp";
};
outputs = { self, nixpkgs, flake-utils, report-temp }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = {};
overlays = [];
};
in
{
devShells.default = report-temp.devShells.${system}.latex;
}
);
}
Binary file not shown.
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
CC:=gcc
CFLAGS:=-g -O2 -Wall -Wpedantic -lm
SRCS:= \
a1.c
EXECS:=$(patsubst %.c,%,${SRCS})
all: ${EXECS}
%: %.c
${CC} ${CFLAGS} $^ -o $@
Executable
BIN
View File
Binary file not shown.
+85
View File
@@ -0,0 +1,85 @@
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
typedef enum {
ABSOLUTE,
DELTA,
NUM_INPUT_TYPE
} InputType;
typedef struct {
double x;
double y;
} Point;
typedef struct {
Point pt;
double fuel;
} Car;
double calc_dist(Point *p1, Point *p2) {
double x2 = (p1->x - p2->x) * (p1->x - p2->x);
double y2 = (p1->y - p2->y) * (p1->y - p2->y);
return sqrt(x2 + y2);
}
void get_info(Car *c) {
printf("Current Position: (%.2f, %.2f)\nFuel Available: %.2f Liter\n",
c->pt.x,
c->pt.y,
c->fuel
);
}
int move(Car *c, Point *dest) {
double d = calc_dist(&c->pt, dest);
if (d > c->fuel) return 0;
c->pt = *dest;
c->fuel -= d;
return 1;
}
int main(void) {
Car myCar = {{0.0,0.0}, 90.0};
Point pt = {0};
while(1) {
get_info(&myCar);
char c;
printf("Continue? [y/n]: ");
scanf("%1[a-zA-Z]", &c);
if (c == 'n') break;
InputType t;
bool isValidInput = false;
while (!isValidInput) {
printf("Select mode [0 = Absolute Position / 1 = Relative Position]: ");
scanf("%u", (unsigned int*)&t);
if (t < NUM_INPUT_TYPE) isValidInput = true;
else puts("Invalid mode!");
}
printf("Input x coordinate: ");
scanf("%lf", &pt.x);
printf("Input y coordinate: ");
scanf("%lf", &pt.y);
switch (t) {
case ABSOLUTE:
break;
case DELTA:
pt.x += myCar.pt.x;
pt.y += myCar.pt.y;
break;
default:
break;
}
int res = move(&myCar, &pt);
if (res == 0) {
puts("Low Fuel!");
}
getchar(); // environment specific fix
}
return 0;
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

+43
View File
@@ -0,0 +1,43 @@
\documentclass[xelatex,a4paper,11pt,ja=standard]{bxjsarticle}
\usepackage{preamble}
\usepackage{simple-title}
\reportauthor{柴田 健琉}
\reporttitle{情報処理2 - 後期第1回課題}
\reportdate{2026年}{10月}{05日}
\turnindate{2026年}{10月}{12日}
\begin{document}
\simpletitle
\section{はじめに}
この課題のプログラムは以下の環境での動作が確認されている:
\begin{itemize}
\item{OS: NixOS 26.05 Yarara, Linux 7.2.8 x86\_64}
\item{CC: GCC 16.2.0}
\item{CFLAGS: \texttt{-g -O2 -Wall -Wpedantic -lm}}
\end{itemize}
\section{課題}
教科書のList 12-9を書き換え, 目標地点の絶対座標を指定する方法と目標地点までの相対距離を指定する方法を選択できるようにしたプログラム.
\lstinputlisting[language=C, caption={Modifiled List 12-9}]{./prog/a1.c}
\subsection{実行結果}
\begin{figure}[H]
\includegraphics[width=12cm]{./prog/res.png}
\end{figure}
\subsection{おおまかな変更点}
\begin{itemize}
\item{列挙体と\texttt{switch}文を用いた距離の指定方法の変更}
\item{実行環境による\texttt{scanf}関数の誤動作を抑制する\texttt{getchar}関数の追加}
\end{itemize}
\end{document}