Untitled
unknown
plain_text
3 years ago
809 B
0
Indexable
Never
#include<sstream> void calMoney(string price, string buy) { // TODO ifstream priceFile; ifstream buyFile; priceFile.open(price); buyFile.open(buy); int ssp; priceFile>>ssp; int gia[ssp + 1]; for(int i = 1; i <= ssp; i++) { int a; priceFile>>a>>gia[i]; } priceFile.close(); string kh; getline(buyFile, kh); stringstream s(kh); int skh; s>>skh; for(int i = 0; i < skh; i++) { string s; getline(buyFile, s); char name = s[0]; int sttsp, sspmua, sotien = 0; s.erase(0,2); stringstream ss(s); while(ss>>sttsp) { ss>>sspmua; sotien += sspmua * gia[sttsp]; } cout<<name<<' '<<sotien<<endl; } buyFile.close(); }