Advertisement
rafid_shad

Going to market.cpp

Nov 11th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct market
  4. {
  5.     string name;
  6.     float quan;
  7. };
  8. int main()
  9. {
  10.     int n,i,j;
  11.     cin>>n;
  12.     for(i=1; i<=n; i++)
  13.     {
  14.         int x;
  15.         float sum=0;
  16.         cin>>x;
  17.         struct market price[x];
  18.         for(j=0; j<x; j++)
  19.         {
  20.             cin>>price[j].name;
  21.             cin>>price[j].quan;
  22.         }
  23.         int y;
  24.         cin>>y;
  25.         struct market price1[y];
  26.         for(j=0; j<y; j++)
  27.         {
  28.             cin>>price1[j].name;
  29.             cin>>price1[j].quan;
  30.         }
  31.         int k;
  32.         for(j=0; j<y; j++)
  33.         {
  34.             for(k=0; k<x; k++)
  35.             {
  36.                 if(price1[j].name == price[k].name)
  37.                 {
  38.                     sum+=(price1[j].quan*price[k].quan);
  39.                 }
  40.             }
  41.         }
  42.         cout<<fixed<<setprecision(2)<<"R$ "<<sum<<endl;
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement