2021-02-01から1ヶ月間の記事一覧
ファイルに、3バイトの文字列を書き込んでファイルの書き込み位置を3バイト先へ進める、という処理を繰り返す。 プログラムを実行すると、いくつかの3バイトの文字列と3バイトのヌル文字列が書き込まれたファイルが作成される。 #include <sys/types.h> /* lseek, open, w</sys/types.h>…
#include <sys/types.h> /* lseek, open, read, write */ #include <stdio.h> /* fflush, perror, printf, putchar */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* read, write */ #include <unistd.h> /* close, lseek, read, write */ int …</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* lseek, open, write */ #include <stdio.h> /* perror */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* write */ #include <unistd.h> /* close, lseek, write */ int main(void) { int fd; if ((fd = open("abc.tx…</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open, read, write */ #include <stdio.h> /* perror */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* read, write */ #include <unistd.h> /* close, read, write */ int main(void) { int ifd; ssize_t cc; char …</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open, read, write */ #include <stdio.h> /* perror */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* read, write */ #include <unistd.h> /* close, read, write */ int main(void) { int ofd; ssize_t cc; char …</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open, read, write */ #include <stdio.h> /* perror */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* read, write */ #include <unistd.h> /* close, read, write */ #define INFILE "input.file" #define OUTFILE…</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open, write */ #include <stdio.h> /* perror */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* write */ #include <unistd.h> /* close, write */ int main(void) { int fd; if ((fd = open("abc.txt", O_WRONLY))…</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open, read */ #include <stdio.h> /* perror, printf */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* read */ #include <unistd.h> /* close, read */ int main(void) { int fd; char buf[6]; /* 5バイトの文字+ヌル文字*/ …</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open, read */ #include <stdio.h> /* perror, printf */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <sys/uio.h> /* read */ #include <unistd.h> /* close, read */ int main(void) { int fd; ssize_t cc; char buf[2]; if ((f…</unistd.h></sys/uio.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
と
#include <sys/types.h> /* open */ #include <stdio.h> /* perror */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ #include <unistd.h> /* close */ int main(void) { int fd; if ((fd = open("empty.file", O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) { perror("open…</unistd.h></fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>
#include <sys/types.h> /* open */ #include <stdio.h> /* perror, printf */ #include <stdlib.h> /* exit */ #include <sys/stat.h> /* open */ #include <fcntl.h> /* open */ int main(void) { int fd; if ((fd = open("abc.txt", O_RDONLY)) == -1) { perror("open"); exit(1); } printf("fd = %d\n", fd); r</fcntl.h></sys/stat.h></stdlib.h></stdio.h></sys/types.h>…
$ cat abc.txt aabbccdd eeffgghh $ od -Ax -tx1 abc.txt 000000 61 61 62 62 63 63 64 64 0a 65 65 66 66 67 67 68 000010 68 0a 000012「-tx1」が16進数で1バイトずつ表示するオプション 「-Ax」が各行左に表示されるアドレス表示を16進数にするオプション
手順 下記のページからフォントファイル(TanukiMagic_1_22.zip)をダウンロードする。 tanukifont.com 「TanukiMagic_1_22.zip」を展開する。 ファイルマネージャを管理者権限で起動する。 $ sudo thunar フォントファイルをディレクトリごと「/usr/share/f…
下記の動画で取り上げられている問題です。 https://www.youtube.com/watch?v=gtURcnVSAtYPythonで計算してみると >>> 7 ** 2019 1790369986451657588966853306877046372859557433177523969707170683383156427954752687631869754787650723302298393030128352…
import numpy as np import matplotlib.pyplot as plt #三角形の頂点(内角が、30°、60°、90°の三角形) p = np.matrix([[0, np.sqrt(3), np.sqrt(3), 0], [0, 0, 1, 0]]) #変換行列(反時計回りに30°回転) th = np.radians(30) A = np.matrix([[np.cos(th), np…
π / 3 を 60° に変換する >>> import math >>> math.pi 3.141592653589793 >>> math.degrees(math.pi/3) 59.99999999999999逆に、60° を π / 3 に変換する >>> math.radians(60) 1.0471975511965976 >>> math.pi / 3 1.0471975511965976
Pythonでmatplotlibを使ったプログラムを実行したら (python3:3577): Gtk-WARNING **: 10:40:37.486: module_path にはテーマ・エンジンがありません: "murrine", という警告が表示された。OSはSparky Linux $ sudo apt install gtk2-engines-murrineで「gtk…
import numpy as np import matplotlib.pyplot as plt #三角形の頂点 (0,0), (2,0), (2,1) p = np.matrix([[0, 2, 2, 0], [0, 0, 1, 0]]) p = np.array(p) #行列を2次元配列に変換する plt.plot(p[0], p[1]) plt.axis('equal') #グラフのX軸とY軸の目盛りの…
plt.text(配置するx座標, 配置するy座標, 表示文字列, rotation=角度) import matplotlib.pyplot as plt x = [0, 3] y = [0, 3] plt.plot(x, y, color='black') plt.text(0, 2, 'abc') plt.text(1, 2, 'abc', rotation=45) plt.text(2, 1, 'abc', rotation=-…
4つの辺をそれぞれ直線のグラフで描く import matplotlib.pyplot as plt x = [0,1] y = [0,2] plt.plot(x, y, color='black') x = [0,2] y = [0,0] plt.plot(x, y, color='black') x = [1,2] y = [2,2] plt.plot(x, y, color='black') x = [2,2] y = [0,2] …
plt.axis('off')を入れる import matplotlib.pyplot as plt x = [0,1] y = [0,2] plt.plot(x, y) plt.axis('off') plt.show()
何も設定しないとx軸とy軸の目盛りの増分が違う import matplotlib.pyplot as plt x = [0,1] y = [0,2] plt.plot(x, y) plt.show() plt.axis('equal')を追加すると目盛りの増分が等しくなる import matplotlib.pyplot as plt x = [0,1] y = [0,2] plt.plot(x…
import matplotlib.pyplot as plt x = [1,2,3] y = [2,4,6] plt.plot(x, y) plt.savefig('a.png')
下記のサイトを使用します texclip.marutank.net サイトの画面 例としてバーゼル問題を入力しています 手順 LaTeXコマンドを入力する(Atomエディタで作成したものをコピペするといいと思います) 左のGenerateボタンをクリックする(またはCtrl + Sを押す)…
だいぶ暖かくなりました 諸磯湾からの富士山 潮が満ちていて先へ行けませんでした ヨットレースでの遭難事故の碑 小網代がレースの出発地だったそうです 三浦の散歩道 〈第90回〉 みうら観光ボランティアガイド協会 | 三浦 | タウンニュース
セルの初期状態をランダムに作成します。 結果はカレントディレクトリにGIFアニメーションで出力されます。 設定値 盤の大きさ:lifegame.pyのBOARD_SIZE 世代数:lifegame.pyのGENERATIONS 初期状態の生きているセルの割合:lifegame.pyのLIFE_RATE GIFで表…
下記のようなデータから [[0, 1, 0, 1], [1, 1, 0, 0], [1, 1, 0, 1], [0, 1, 1, 0]]下記のような画像を作成するプログラムです。 from PIL import Image, ImageDraw def draw_square(row, column, color): x1 = column * square_size y1 = row * square_siz…
スタートメニューを表示 Alt + F1 ファイルマネージャーを起動 Windows + e すべてのウィンドウを最小化する Windows + d
Alt + F2 を押す 実行するプログラムを入力するウィンドウが表示されるのでターミナルのプログラム名を入力して、Enter を押す