C/C++の宿題を片付けます 91代目 at TECH
[2ch|▼Menu]
240:デフォルトの名無しさん
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

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