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

–â‘èPDF N‰Èî•ñƒlƒbƒgƒ[ƒN“±“üƒ†ƒjƒbƒg‡UiCŒ¾Œê‡Uj

N/A
N/A
Protected

Academic year: 2018

シェア "–â‘èPDF N‰Èî•ñƒlƒbƒgƒ[ƒN“±“üƒ†ƒjƒbƒg‡UiCŒ¾Œê‡Uj"

Copied!
2
0
0

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

全文

(1)

C言語Ⅱ 演習(4-2) ~構造体(2)~ 1

C

言語Ⅱ

演習

(

-2)

~構造体

(2)

教科書 12章

以下 問題 関 るプ グラ を作成し,ソ スプ グラ を入力後,ビ ,実行し 実行結果を確認し さい. 実行 正しく確認 たら,プ グラ を ポ 用紙 写し,教員あるい TA 確認を受け 提出し さい.

お, ポ 用紙 問題番号,学籍番号,氏名を必 書くこ .

問題1. 構造体 型宣言、構造体 配列、 ンバ 初期化 使い方

構造体を使 以 プログラ を作成 い

構造体 data を作成 struct data を使う

構造体 data 要素

char name[20]; //19文字 前を入 int hp; //体力を入

int str; //腕力を入

構造体dataを使 実体 monster[3]を作成 monster[3]を以 値 初期設定

{"Slime" , 200, 185 }, {"Skelton", 156, 144 } {"Snake", 278, 77 }

右 実行結果 う monster[3] べ 値を表示

実行結果例

前=Slime

体力=200

腕力=185

前=Skeleton

体力=156

腕力=144

前=Snake

体力=278

腕力=77

問題2. 構造体 typedef宣言、構造体 配列

問題1 プログラ け 構造体 宣言をtypedef宣言を使用

data型 書き換え 問題1 実行結果を得 う

い typedef 宣言 い 構造体タグ 省略 い

実行結果例 上記

問題3. 構造体 typedef宣言、構造体 配列

次 ンバを持 構造体をtypedef宣言を使用 data型 準備 い typedef 宣言 い 構造体タグ

省略 い

char型 配列変数name 配列要素数:20 int型 変数height

double型 変数weight

data型 配列変数studentを要素数100 宣言 続い

右 実行結果 示 う 2 分 情報をstudent 代入 そ

後 2 分 情報を表示 プログラ を作成 い

実行結果例 前:Abe

身長:165

体重:58.7

前:Tanaka

身長:158

体重:61.0

前=Abe

身長=165[cm]

体重=58.7[kg]

前=Tanaka

身長=158[cm]

体重=61.0[kg]

(2)

C言語Ⅱ 演習(4-2) ~構造体(2)~ 2 問題4. 構造体 typedef宣言、 ンバ 設定、ファイ

4 分 学籍番号 前 次 内容 test724.txtファイ

ルを作成 い

012345 Tanaka 022222 Ogawa 031313 Kikuchi 043210 Kagawa

学籍番号(6 桁) 前(最大10 文字) 試験 成績(0~100 点) 3種類 デ タを格納 構造体をtypedef宣言を用い list型 作成 い

続い 4 分 情報を格納 き 配列変数studentをlist型 宣言 test724.txtファイル 1 分 情報を配列変数student

要素 読 込 試験 成績 値を入力 を4

分行 後 右 う 表示 プログラ を作成 い

実行結果例

学籍番号(012345) 氏 (Tanaka):72

学籍番号(022222) 氏 (Ogawa):100

学籍番号(031313) 氏 (Kikuchi):68

学籍番号(043210) 氏 (Kagawa):73

学籍番号 前 成績

012345 Tanaka 72 022222 Ogawa 100 031313 Kikuchi 68 043210 Kagawa 73

※ はキーボード入力部

参照

関連したドキュメント

Theorem 3 implies strong asymptotic stability results: the energy of strong solutions decays to zero, with an explicit decay rate

There is a bijection between left cosets of S n in the affine group and certain types of partitions (see Bjorner and Brenti (1996) and Eriksson and Eriksson (1998)).. In B-B,

Actually a similar property shall be first de- rived for a general class of first order systems including the transport equation and Schr¨odinger equations.. Then we shall consider

Hence, the degree theory constructed in [1] is an extension of the classical Leray–Schauder degree in Hilbert space.. It is unique, single-valued and has the usual properties of

Lair and Shaker [10] proved the existence of large solutions in bounded domains and entire large solutions in R N for g(x,u) = p(x)f (u), allowing p to be zero on large parts of Ω..

We prove a continuous embedding that allows us to obtain a boundary trace imbedding result for anisotropic Musielak-Orlicz spaces, which we then apply to obtain an existence result

This concludes the proof that the Riemann problem (1.6) admits a weak solution satisfying the boundary condition in the relaxed sense (1.6c).... The two manifolds are transverse and

This paper is a sequel to [1] where the existence of homoclinic solutions was proved for a family of singular Hamiltonian systems which were subjected to almost periodic forcing...