Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct market
- {
- string name;
- float quan;
- };
- int main()
- {
- int n,i,j;
- cin>>n;
- for(i=1; i<=n; i++)
- {
- int x;
- float sum=0;
- cin>>x;
- struct market price[x];
- for(j=0; j<x; j++)
- {
- cin>>price[j].name;
- cin>>price[j].quan;
- }
- int y;
- cin>>y;
- struct market price1[y];
- for(j=0; j<y; j++)
- {
- cin>>price1[j].name;
- cin>>price1[j].quan;
- }
- int k;
- for(j=0; j<y; j++)
- {
- for(k=0; k<x; k++)
- {
- if(price1[j].name == price[k].name)
- {
- sum+=(price1[j].quan*price[k].quan);
- }
- }
- }
- cout<<fixed<<setprecision(2)<<"R$ "<<sum<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement