C/C++の宿題を片付けます 91代目 at TECH
[2ch|▼Menu]
169:デフォルトの名無しさん
07/06/25 17:42:43
>>159
#include <stdio.h>

typedef struct tag_student_t{
    double eng, math;
    int id;
}student_t;

void InputData(student_t s[], int n){
    int i;
    for(i = 0; i < n; i++){
        printf("student %d\ninput data (id, eng, math) : ", i + 1);
        scanf("%d%lf%lf", &s[i].id, &s[i].eng, &s[i].math);
    }
}

int main(void){
    student_t s[4];
    double max = -1;
    int i, i_max = 0;
   
    InputData(s, 4);
   
    for(i = 0; i < 4; i++)
        if(max < s[i].eng + s[i].math)
            i_max = i, max = s[i].eng + s[i].math;
   
    printf("id : %d eng : %.3f math : %.3f sum : %.3f\n",
    s[i_max].id, s[i_max].eng, s[i_max].math, s[i_max].eng + s[i_max].math);
   
    return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4769日前に更新/213 KB
担当:undef