URI Solution 1281 Going to the Market | Data Structures
URI Online Judge Solution | Data structures
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1281
Problem Name: URI Problem 1281 Going to the Market
Problem Number : URI Problem 1281 Going to the Market Solution
Online Judge : URI Online Judge Solution
Level: Data structures
Solution Language : C, C plus plus
URI Solution 1281 Going to the Market Code in CPP:
#include <iostream> #include <iomanip> #include <cstring> #include <map> using namespace std; int main() { int n, m; float q, sumAll, tmp; string s, nome, qtd; size_t pos; cin >> n; cin.ignore(); while(n--) { map<string, float> map; sumAll = 0; cin >> m; cin.ignore(); while(m--) { getline(cin, s); size_t pos = s.find(' '); nome = s.substr(0, pos); qtd = s.substr(pos); q = atof(qtd.c_str()); map.insert(pair<string,float>(nome,q)); } cin >> m; cin.ignore(); while(m--) { getline(cin, s); size_t pos = s.find(' '); nome = s.substr(0, pos); qtd = s.substr(pos); q = atof(qtd.c_str()); tmp = map[nome]; sumAll += (q * tmp); } cout << "R$ " << fixed << setprecision(2) << sumAll << '\n'; } return 0; }
Tag: Uri solve 1281 Going to the Market , Uri solution 1281 Going to the Market , URI oj Solve 1281 Going to the Market
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks