Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
基礎情報処理演習 (6)実数と繰り返し
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
自然言語処理研究室
October 24, 2013
Programming
8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
基礎情報処理演習 (6)実数と繰り返し
自然言語処理研究室
October 24, 2013
More Decks by 自然言語処理研究室
See All by 自然言語処理研究室
データサイエンス14_システム.pdf
jnlp
0
430
データサイエンス13_解析.pdf
jnlp
0
550
データサイエンス12_分類.pdf
jnlp
0
380
データサイエンス11_前処理.pdf
jnlp
0
510
Recurrent neural network based language model
jnlp
0
190
自然言語処理研究室 研究概要(2012年)
jnlp
0
170
自然言語処理研究室 研究概要(2013年)
jnlp
0
130
自然言語処理研究室 研究概要(2014年)
jnlp
0
160
自然言語処理研究室 研究概要(2015年)
jnlp
0
240
Other Decks in Programming
See All in Programming
iOSDCのペンライトを自動制御したい!
akkeylab
0
140
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
310
Workers Cache を知る
syumai
0
310
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
120
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.5k
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
190
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
2.8k
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.4k
一人だけ、Kiroが静止する日
hideg
0
140
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.6k
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
460
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Scaling GitHub
holman
464
140k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
890
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
The Cult of Friendly URLs
andyhume
79
7k
Designing for Performance
lara
611
70k
Mind Mapping
helmedeiros
1
380
The Spectacular Lies of Maps
axbom
PRO
1
1k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
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