0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

独習プログラミングの備忘録 2 後編 【式と演算子】

Last updated at Posted at 2022-10-03

日曜日はお休みしていました。

~学んだこと~
・キャスト演算子(cast operator)は強制的に型を変換できるが、情報の一部が失われる
(double型3.2 → int型3)

・異なる型で算術演算を行うと、型をそろえてから処理される
(8.5 / 2 → int型の2は、double型の2.0に変換)

・プレースホルダ(place holder)はデータ型の用途によって使い分ける
(整数 → %d、小数 → &f、文字列 → %s)

・typedef char ○○○[1024]は、最大千文字程度の文字列を利用可能にするおまじない

・printf()の使用には、#include ≪stdio.h≫が必要 (画面に表示)

・scanf()の使用には、#include ≪stdio.h≫が必要 (文字列入力を受け付ける)

・atoi()の使用には、#include ≪stdlib.h≫が必要 (文字列を整数に変換)

・srand((unsigned)time(NULL))の使用には、#include ≪stdlib.h≫と#include ≪time.h≫が必要
(乱数生成の準備)

・rand()の使用には、#include ≪stdlib.h≫が必要 (乱数を生成し、範囲を指定)

~感想~
乱数生成は、面白みとハラハラドキドキを出すために様々な場面で使用されている。
(パーティゲームのさいころ、RPGの与えたダメージ、FPS・TPSの弾道のブレ)
これらをマスターして簡易的なゲームを制作してみたいと感じた。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?