Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
基礎情報処理演習 (6)実数と繰り返し
Search
自然言語処理研究室
October 24, 2013
Programming
0
8k
基礎情報処理演習 (6)実数と繰り返し
自然言語処理研究室
October 24, 2013
Tweet
Share
More Decks by 自然言語処理研究室
See All by 自然言語処理研究室
データサイエンス14_システム.pdf
jnlp
0
410
データサイエンス13_解析.pdf
jnlp
0
520
データサイエンス12_分類.pdf
jnlp
0
360
データサイエンス11_前処理.pdf
jnlp
0
490
Recurrent neural network based language model
jnlp
0
150
自然言語処理研究室 研究概要(2012年)
jnlp
0
150
自然言語処理研究室 研究概要(2013年)
jnlp
0
120
自然言語処理研究室 研究概要(2014年)
jnlp
0
140
自然言語処理研究室 研究概要(2015年)
jnlp
0
220
Other Decks in Programming
See All in Programming
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
430
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
690
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8k
Windows on Ryzen and I
seosoft
0
260
Claude Code Skill入門
mayahoney
0
290
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
130
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
130
Fundamentals of Software Engineering In the Age of AI
therealdanvega
1
250
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
390
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3.3k
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
210
文字コードの話
qnighy
44
17k
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Thoughts on Productivity
jonyablonski
75
5.1k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
190
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
210
Evolving SEO for Evolving Search Engines
ryanjones
0
150
Statistics for Hackers
jakevdp
799
230k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
470
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
Transcript
基礎情報処理演習 (6) 実数と繰り返し 山本和英 長岡技術科学大学 1
整数と実数 2
変数は最初にまとめて宣言する (正解) int idt; double ddt; idt = 100; ddt
= 23.45 ... (間違い) int idt; idt = 100; double ddt; ddt = 23.45 3 途中で変数宣言 してはいけない
データ型 int 整数 double 実数 char 文字 他にもありますがこれだけで十分です。 4
そもそも「実数」て何だ? 一言で言えば、整数で表現できない数です。 (1) 小数点以下を含む数字、小さな数 (2) (±21億ぐらい)よりも大きな数 実数(浮動小数点数)は整数と記憶方法が違います。 このため非常に広範囲の数を表現できますが誤差を 含むので、int型で表現できる数は必ず int
を使っ てください。 5
演算子 演算子とは、計算などをする記号のことです。 算術演算子 + 加算 - 減算 * 乗算 /
除算 % 余り (7 % 3 = 1) 6
割り算に注意! 整数どうしの計算は必ず整数で計算する。 例えば、 printf (“%f\n”, 5 / 7); を実行すると、(出力書式で実数(%f)指定し ていても全く関係なく)
0.0000 が出力され る。 7
実数で計算したい時はどうするの? printf (“%f\n”, 5.0 / 7); printf (“%f\n”, 5 /
7.0); printf (“%f\n”, 5.0 / 7.0); printf (“%f\n”, (double) 5 / 7); (double) については、次のスライド参照。 8
キャスト演算子 型変換したい時に使う。 printf (“%f\n”, (double) 5 / 7); 整数の 5
を実数 (5.0) と理解することで、 割り算を実数で行う。 9
代入演算子 単純代入演算子: = p = 0; // 普通の使い方 a =
b = 3; // 多重代入もできる 複合代入演算子: += -= *= /= など k += 1; // k=k+1; と同じ 10
printf の書式 %d int %f double %c char %s (文字列)
表示幅を指定することもできる %5d intを5文字で 11
scanf_s の書式 %d int %lf double %c char %s (文字列)
double型以外は同じ。 12
数学関数 #include <math.h> を冒頭につけると下記の関数が使える。 三角関数 sin, cos, tan (ラジアンで入力することに注意) 平方根
sqrt 指数・対数 exp, log, log10 絶対値 fabs べき乗 pow など 13
for文による繰り返し 14
for (i=1; i<=10; i=i+1){ } for文の繰り返し 15
赤字部分(前ページ)が +1 の場合は 下記PADに対応する。 a ← 1 ~ 10 ※<=(関係演算子)は≦という意味ですが、
詳しくは次回に... 16
i <= 10 i ← 1 i ← i +
1 for (i=1; i<=10; i=i+1){ } 17
for (i=1; i<=10; i=i+1){ } i<=10 の間繰り返す (継続条件) 最初は i=1
にする (初期化) 繰り返しごとにiを増加 (変化量) 18
for (i=10; i>=1; i=i-1){ } 継続条件なので、 i>=1 (i<=1ではない!) もしカウントダウンしたかったら... 19