zoukankan      html  css  js  c++  java
  • C语言 · 提货单(P1101)

    算法训练 P1101  
    时间限制:1.0s   内存限制:256.0MB
        
      
      有一份提货单,其数据项目有:商品名(MC)、单价(DJ)、数量(SL)。定义一个结构体prut,其成员是上面的三项数据。在主函数中定义一个prut类型的结构体数组,输入每个元素的值,计算并输出提货单的总金额。
      输入格式:第一行是数据项个数N(N<100),接下来每一行是一个数据项。商品名是长度不超过100的字符串,单价为double类型,数量为整型。
      输出格式:double类型的总金额。
    输入:
      4
      book 12.5 3
      pen 2.5 10
      computer 3200 1
      flower 47 5

    输出:
      3497.500000
     
     1 #include<stdio.h>
     2 #include<string.h>
     3 struct good{
     4     char MC;
     5     double DJ;
     6     int SL;
     7 };
     8 int main(){
     9     int N;
    10     double All=0.0;
    11     scanf("%d",&N);
    12     struct good *g = new struct good[N];
    13     for(int i=0;i<N;i++){
    14         scanf("%s %lf %d",&g[i].MC,&g[i].DJ,&g[i].SL);
    15         All += g[i].DJ*g[i].SL;
    16     }
    17     printf("%lf",All);
    18     return 0;
    19 }
  • 相关阅读:
    P1541
    P1004
    P1006
    高精度
    数组
    递归
    顺序结构
    循环结构
    变量
    分支结构
  • 原文地址:https://www.cnblogs.com/panweiwei/p/6498805.html
Copyright © 2011-2022 走看看