一本通1104:计算书费(Yibentong 1104: calculating book fees)-其他
一本通1104:计算书费(Yibentong 1104: calculating book fees)
1104:计算书费
【题目描述】
下面是一个图书的单价表:
计算概论 28.9元/本
数据结构与算法 32.7元/本
数字逻辑 45.6元/本
C++程序设计教程 78元/本
人工智能 35 元/本
计算机体系结构 86.2元/本
编译原理 27.8元/本
操作系统 43元/本
计算机网络 56元/本
JAVA程序设计 65元/本
给定每种图书购买的数量,编程计算应付的总费用。
【输入】
输入一行,包含10个整数(大于等于0,小于等于100),分别表示购买的《计算概论》、《数据结构与算法》、《数字逻辑》、《C++程序设计教程》、《人工智能》、《计算机体系结构》、《编译原理》、《操作系统》、《计算机网络》、《JAVA程序设计》的数量(以本为单位)。每两个整数用一个空格分开。
【输出】
输出一行,包含一个浮点数f,表示应付的总费用。精确到小数点后一位。
【输入样例】
1 5 8 10 5 1 1 2 3 4
【输出样例】
2140.2代码如下:
#include <stdio.h>
int main()
{
double price[15]={28.9,32.7,45.6,78,35,86.2,27.8,43,56,65};
int num[15];
double sum=0;
int i;
for(i=0;i<10;i++)
{
scanf("%d",&num[i]);
sum+=num[i]*price[i];
}
printf("%.1f\n",sum);
return 0;
}
1104: calculate book cost
[Title Description]
The following is a unit price table of books:
Introduction to calculation 28.9 yuan / book
Data structure and algorithm 32.7 yuan / book
Digital logic 45.6 yuan / book
C + + programming tutorial 78 yuan / book
Artificial intelligence 35 yuan / book
Computer architecture 86.2 yuan / book
Compilation principle 27.8 yuan / book
Operating system 43 yuan / book
Computer network 56 yuan / book
Java programming 65 yuan / book
Given the quantity of each book purchased, the total cost payable is calculated by programming.
[input]
Enter a line containing 10 integers (greater than or equal to 0 and less than or equal to 100), which respectively represent the number of purchased introduction to computing, data structure and algorithm, digital logic, C + + programming tutorial, artificial intelligence, computer architecture, compilation principle, operating system, computer network and Java programming (in this unit). Every two integers are separated by a space.
[output]
Output a line containing a floating-point number f, representing the total fee payable. Accurate to one decimal place.
[input example]
1 5 8 10 5 1 1 2 3 4
[output example]
2140.2代码如下:
#include <stdio.h>
int main()
{
double price[15]={28.9,32.7,45.6,78,35,86.2,27.8,43,56,65};
int num[15];
double sum=0;
int i;
for(i=0;i<10;i++)
{
scanf("%d",&num[i]);
sum+=num[i]*price[i];
}
printf("%.1f\n",sum);
return 0;
}