标签:换行 com tor cout second src space code ios
1 /* 2 * 换行好烦人呀! 3 */ 4 #include <iostream> 5 #include <map> 6 #include <string> 7 using namespace std; 8 map<string,map<string,int>> m; 9 int N; 10 int main() { 11 cin >> N; 12 while (N--) { 13 int n; 14 cin>>n; 15 for (int i = 0; i < n; ++i) { 16 string place, fruit; 17 int q; 18 cin >> fruit >> place; 19 cin >> q; 20 m[place][fruit] += q;//cin以后储存,再把地名放在前面 21 } 22 for (map<string, map<string, int>>::iterator i = m.begin(); i != m.end(); i++) { 23 cout << i->first << endl; 24 for (map<string, int>::iterator j = (i->second).begin(); j != (i->second).end(); j++) { 25 cout << " |----" << j->first << "(" << j->second << ")" <<endl; 26 27 } 28 29 } 30 31 m.clear();//最后别忘了清空!!! 32 if (N) 33 cout <<endl; 34 } 35 }
标签:换行 com tor cout second src space code ios
原文地址:https://www.cnblogs.com/zhmlzhml/p/13339301.html