C/C++の宿題を片付けます 91代目at TECH
C/C++の宿題を片付けます 91代目 - 暇つぶし2ch240:デフォルトの名無しさん
07/06/26 10:30:48
>>238
#include <stdio.h>

typedef struct tag_stock_t{
    double price;
    int quantity;
}stock_t;

int main(void)
{
    stock_t x[4];
    double price_sum = 0, price_ave;
    int i, num = 0;
   
    for(i = 0; i < 4; i++)
        scanf("%lf%d", &x[i].price, &x[i].quantity);
   
    for(i = 0; i < 4; i++){
        price_sum += x[i].price*x[i].quantity;
        num += x[i].quantity;
    }
   
    price_ave = price_sum/num;
   
    printf("%.1f %d\n", price_ave, num);
   
    return 0;
}


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