• 検索結果がありません。

eisan

N/A
N/A
Protected

Academic year: 2018

シェア " eisan"

Copied!
8
0
0

読み込み中.... (全文を見る)

全文

(1)

前回: 変数 整数 計算

フ ロク ラム 作成 実行

スコ 作成 キス

コンパ 処理 コンパ

フ ロク ラム 実行 コマン

C 作成

myc hello2.c 作成

[右 ] [新規作成]

hello2.c

Visual Studio .NET 起動

cd C:¥myc 移動

hello2.c コンパ 処理

hello2.exe 作成さ

コマン

hello2.exe[Enter] 実行

実行結果 確認

1

#include <stdio.h> int main(void){ int n;

n = 1+2+3+4+5;

printf("answer=%d¥n", n); return 0;

}

(2)

~ ま 和 計算

#include <stdio.h>

int main(void){

int n;

n = 1+2+3+4+5;

printf("answer=%d¥n", n);

return 0;

}

2

(3)

文法 確認

int n;

■変数宣言 定義

●変数 int 変数 定義

●こ 整数値 格納

指定 格納さ た値 参照

int integer 整数 意味

n = 1+2+3+4+5; ■代入

●ま 右側 計算 結果 変数 格納

▼変数 宣言 使う

printf("answer=%d¥n", n); ■出力

書式 従っ 出力さ

% 整数型 対応 変数 出力

¥n 改行

▼通常 画面 出力

3

(4)

1.1 1.5 合計 計算

/* 1.1 1.5 合計 */

#include <stdio.h>

int main(void){

double n;

n = 1.1 + 1.2 + 1.3 + 1.4 + 1.5;

printf("answer=%f¥n", n);

return 0;

}

4

小数点以

double

格納

用意

1.11.5

変数

小数点以

double 指定

■コ 注釈

/* */ 囲う

●複数行 また

良い

▼こ 実行 影響

与え

(5)

数値出力

数値 printf 出力 指定

テ ータ 何文字幅 出力

テ ータ (10 進数 出力

■ 外へ 出 こ 出力 言いま

■ 指定 た 変換仕様 あ ま

▼変換仕様 表

%d 10進数 整数部 出力

%x 16進数

%f 浮動小数点数 小数点以 10進数

%c 文字

%s 文字列

▼変換仕様以外 文字 まま出力 ¥

続く 文字 特殊文字 取扱い

5

(6)

算術演算子

6

演算子 説明 記述例 減算 乗算 除算

nn = a+b; printf( a+b=%d¥n ,nn); nn = a-b; printf( -b=%d¥n ,nn); nn = a*b; printf( * =%d¥n ,nn); nn = a/b; printf( / =%d¥n ,nn); nn = a%b; printf( %% =%d¥n ,nn);

d1=9.0; d2=4.0;

dd=d1/d2; printf( d2/d2=%f¥n ,dd);

return 0; }

%% % 自身 文字 出力

#include <stdio.h>

int main(void)

{

int a, b, nn;

double d1, d2, dd;

a = 10;

b = 3;

(7)

算術演算子 優先順位

(1) * / % + - 処理

(2) * / % 優先順位 ク ルーフ

(3) + -

(4) 優先順位 演算子 使わ

左側 処理

(5) 優先 処理

■ 例

• 1+2*3 → 7 1*2+3 → 5

• 1+2+3 → 6 4* 5+6 →44

7

(8)

練習

次 フ ロク ラム 入

力 実行 [実行

結果 書 さい]

#include <stdio.h> int main(void){

int a,b;

a=12345; b=54321; printf("%d¥n", a+b); return 0;

}

8

3 自分

学生番号 前

出力 次

足 算 出

順 実行

フ ロク ラム 作成 さい

[フ ロク ラム 書 さい]

次 フ ロク ラム 入

力 実行 [実行

予想 実行結

果 書 さい]

#include <stdio.h> int main(void){

int a,b; a=2; b=3;

printf("%d¥n", a+b); a=9; b=

return 0; }

参照

関連したドキュメント

(The Elliott-Halberstam conjecture does allow one to take B = 2 in (1.39), and therefore leads to small improve- ments in Huxley’s results, which for r ≥ 2 are weaker than the result

[r]

“Breuil-M´ezard conjecture and modularity lifting for potentially semistable deformations after

lines. Notice that Theorem 4 can be reformulated so as to give the mean harmonic stability of the configuration rather than that of the separate foliations. To this end it is

S., Oxford Advanced Learner's Dictionary of Current English, Oxford University Press, Oxford

this to the reader. Now, we come back to the proof of Step 2. Assume by contradiction that V is not empty.. Let u be the minimal solution with the given boundary values and let P be

At the end of the section, we will be in the position to present the main result of this work: a representation of the inverse of T under certain conditions on the H¨older

支払方法 支払日 ※② 緊急時連絡先等 ※③.