2019-10-11 20:34:52 +00:00
|
|
|
/*
|
|
|
|
* Student: S.K. Soekhlal
|
|
|
|
* Number: 4860632
|
|
|
|
* Assignment: 4.3
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include<stdio.h>
|
|
|
|
#include<stdlib.h>
|
|
|
|
#include<math.h>
|
|
|
|
|
|
|
|
int main(){
|
2019-10-24 14:17:22 +00:00
|
|
|
int m,n,i,j,c; /*Declare Variables*/
|
|
|
|
double price[100]; /*Declare array price*/
|
|
|
|
int matrix[100][100]; /*Declare array matrix*/
|
|
|
|
scanf("%d",&n); /*Get amount of items*/
|
|
|
|
for(i = 0; i<n; i++){ /*Loop to get price for every item and store them into array price*/
|
|
|
|
scanf("%lf", &price[i]);
|
|
|
|
}
|
|
|
|
scanf("%d",&m); /*Get amount of customers*/
|
|
|
|
for(j = 0; j<m; j++){ /*Loop the following code for every custromer*/
|
|
|
|
for (c = 0; c < n; c++){ /*Loop to get amount of every item and store amount of customers and amount of items they buy in matrix*/
|
|
|
|
scanf("%d",&matrix[c][j]);
|
2019-10-11 20:34:52 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-24 14:17:22 +00:00
|
|
|
for (j = 0; j<m; j++){ /*Loop the following code for every custromer*/
|
2019-10-11 20:34:52 +00:00
|
|
|
float total = 0;
|
2019-10-24 14:17:22 +00:00
|
|
|
for(c = 0; c < n; c++){ /*Calculating total*/
|
|
|
|
total += matrix[c][j]*price[c];
|
2019-10-11 20:34:52 +00:00
|
|
|
}
|
|
|
|
printf("%.2f\n", total);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|