-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshop.c
54 lines (45 loc) · 1.01 KB
/
shop.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
typedef struct shop {
char masanpham[10];
int gia;
} shop;
typedef struct giohang {
char ma[10];
int soluong;
} giohang;
int main() {
shop arr1[100];
giohang arr2[100];
char id[10];
int count = 0;
for (int i = 0; i < 100; i++) {
scanf("%s", id);
if (strcmp(id, "-1") == 0) {
break;
}
scanf("%d", &arr1[i].gia);
strcpy(arr1[i].masanpham, id);
count++;
}
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s", arr2[i].ma);
scanf("%d", &arr2[i].soluong);
}
int sum = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < count; j++) {
if (strcmp(arr1[j].masanpham, arr2[i].ma) == 0) {
sum += arr1[j].gia * arr2[i].soluong;
break;
}
}
}
printf("%d", sum);
return 0;
}