URI ONLINE JUDGE SOLUTION 1010 - Simple Calculate
Problem:
In this problem, the task is to read a code of a
product 1, the number of units of product 1, the price for one unit of
product 1, the code of a product 2, the number of units of product 2 and
the price for one unit of product 2. After this, calculate and show the
amount to be paid.
Input
The input file contains two lines of data. In each
line there will be 3 values: two integers and a floating value with 2
digits after the decimal point.
Output
The output file must be a message like the following example where "Valor a pagar" means Value to Pay. Remember the space after ":" and after "R$" symbol. The value must be presented with 2 digits after the point.
Solution:
#include<stdio.h>
int main()
{
int a[4];
double b[2],paid;
scanf("%d%d%lf",&a[0],&a[1],&b[0]);
scanf("%d%d%lf",&a[2],&a[3],&b[1]);
paid=a[1]*b[0]+a[3]*b[1];
printf("VALOR A PAGAR: R$ %0.2lf\n",paid);
return 0;
}
Solution:
#include<stdio.h>
int main()
{
int a[4];
double b[2],paid;
scanf("%d%d%lf",&a[0],&a[1],&b[0]);
scanf("%d%d%lf",&a[2],&a[3],&b[1]);
paid=a[1]*b[0]+a[3]*b[1];
printf("VALOR A PAGAR: R$ %0.2lf\n",paid);
return 0;
}
Comments
Post a Comment