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

‰ð“š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

言語Ⅱ模擬試験

[

構造体

]

解答

struct person

double sum =0;

double avg;

struct person student[3];

FILE *fp;

fp=fopen(

"test.txt"

,

"r"

);

fp==NULL

fscanf(fp,"%s",student[i].name);

fscanf(fp,"%lf",&student[i].h);

sum=sum+student[i].h;

avg=(double)sum/3.0;

<参考:すべ のプログラム>

#include<stdio.h>

struct person {

char name[10]; double h;

}; //person 言う名の構造体を作成

int main(void){

(2)

double sum =0; //合計値を入 変数 double avg; //平均値を入 変数

struct person student[3]; //構造体 studentを人分実体を作成。

FILE *fp;

fp=fopen("test.txt","r");

//ファイルを開くのを2行 記述

if (fp==NULL){

printf("error\n"); return 1;

} //ファイルエラー処理

for (i=0;i<3;i++){

fscanf(fp,"%s",student[i].name); //name要素を読 込 fscanf(fp,"%lf",&student[i].h); //h 要素を読 込 sum=sum+student[i].h; // h の合計値を計算 }

fclose(fp);

avg=(double)sum/3.0; //平均値を(double) 計算 printf("%lf\n",avg);

参照

関連したドキュメント

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...