Books costing payable

Description questions
The following is a book monovalent Table: Calculation Introduction 28.9 yuan / The data structures and algorithms 32.7 yuan / present digital logic 45.6 yuan / local C ++ programming Tutorial 78 yuan / present AI 35 yuan / present computer architecture 86.2 yuan / present compiled principle 27.8 yuan / this operating system 43 yuan / the computer network 56 yuan / the JAVA programming 65 / each present given the number of books purchased, programmed to calculate the total cost payable.
Input Format
Input line, comprising 10 integer (greater than or equal to 0 and less than or equal to 100), respectively, for later "Calculating Introduction", "Data Structures and Algorithms", "Digital Logic", "C ++ Programming Guide", "artificial intelligence", the number of "computer architecture", "compiler theory", "operating system", "computer network", "JAVA programming" (in this as a unit). Every two integers separated by a space.
Output Format
Output one line containing a float f, represents the total cost payable. One decimal place.
Sample input
1 5 8 10 5 1 1 2 3 4
Sample Output
2140.2
#include <stdio.h>
int main()
{
    int a[10],i;
    double sum;
    while(scanf("%d",a)!=EOF){
        for(i=1;i<10;i++){
            scanf("%d",a+i);
        }
        sum=a[0]*28.9+a[1]*32.7+a[2]*45.6+a[3]*78+a[4]*35+a[5]*86.2+a[6]*27.8+a[7]*43+a[8]*56+a[9]*65;
        printf("%.1lf\n",sum);
    }
    return 0;
}

Published 32 original articles · won praise 9 · views 70000 +

Guess you like

Origin blog.csdn.net/yi__cao/article/details/78515213