STL || HDU 1263 水果
map可以映射map……
然后在map里面会自己排序
惊了
注意输出格式 回车的输出
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <map>
- using namespace std;
- map<string, map<string, int> > mp;
- int main()
- {
- int T;
- cin >> T;
- while(T--)
- {
- int n;
- cin >> n;
- mp.clear();
- string place, fruit;
- int num;
- for(int i = ; i < n; i++)
- {
- cin >> fruit >> place >> num;
- mp[place][fruit] += num;
- }
- for(map<string, map<string, int> >::iterator iter1 = mp.begin(); iter1 != mp.end(); iter1++)
- {
- cout << iter1 -> first << endl;
- for(map<string, int>::iterator iter2 = iter1->second.begin(); iter2 != iter1->second.end(); iter2++)
- {
- cout << " |----" << iter2->first << "(" << iter2->second << ")" << endl;
- }
- }
- if(T) cout << endl;
- }
- return ;
- }
STL || HDU 1263 水果的更多相关文章
- HDU 1263 水果 (STL map)
水果 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- hdu 1263 水果 【二维map】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 题目大意: Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ ...
- 题解报告:hdu 1263 水果
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营 ...
- hdu 1263 水果
Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样J ...
- HDU 1263(水果统计 **)
题意是对水果的产地和种类进行统计再按格式输出. 代码如下: #include <bits/stdc++.h> using namespace std; struct node { ],pl ...
- hdu 1263 水果 结构的排序+sort自定义排序
水果 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- HDU 1263 水果 结构体排序
解题报告:一个结构体排序的题,用了一个运算符重载,要注意的是不同的地方可能会产相同的水果,一开始没注意. #include<cstdio> #include<cstring> ...
- hdu 1263 水果 (嵌套 map)
水果Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissio ...
- ACM 水果 hdu 1263 一题多解
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1263 文章末有相应的一些测试数据供参考. 传统的数组解题方式 思路一: 三种属性的数据放在一个结构体里面, ...
随机推荐
- k8s-部署dashboard1.10.1-十七
一.获取镜像和填坑 我的k8s是1.13.1,这里dashboard用的1.10.1: 由于国内不能访问Google,而且大部分人可能也没有其他途径访问:只能在阿里云或者其他镜像网站上获取了: 镜像获 ...
- shell脚本只提供整数算术运算(三种方式)—((表达式))、let "表达式"、value=`expr 表达式右边` (转载)
转自:http://blog.163.com/xychenbaihu@yeah/blog/static/132229655201131055455754/ 数值运算: 在bash中只提供了整数运算,一 ...
- python mixin到底是什么 django
1.什么是Mixin 在面向对象编程中,Mixin是一种类,这种类包含了其他类要使用的方法,但不必充当其他类的父类.其他类是如何获取Mixin中的方法因语言的不同而不同.所以有时候Mixin被描述为' ...
- Swift3.0 控制流
常用的一些判断方式 //for in let numberList = [, , , , ] //获取第一个元素 !拆包 print(numberList.first!)//1 //获取最后一个元素 ...
- spark 机器学习 朴素贝叶斯 原理(一)
朴素贝叶斯算法仍然是流行的挖掘算法之一,该算法是有监督的学习算法,解决的是分类问题,如客户是否流失.是否值得投资.信用等级评定等多分类问题.该算法的优点在于简单易懂.学习效率高.在某些领域的分类问题中 ...
- TCP Socket通信详细过程
下面这篇文章是参考"骏马金龙"博客中 不可不知的socket和TCP连接过程 https://www.cnblogs.com/f-ck-need-u/p/7623252.html ...
- _bzoj1029 [JSOI2007]建筑抢修【贪心 堆】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1029 经典的贪心问题,不解释. #include <cstdio> #inclu ...
- Educational Codeforces Round 19 A
Description Given a positive integer n, find k integers (not necessary distinct) such that all these ...
- Monitor CodeForces - 846D
题目 题意:有一个n*m的显示屏,有q个坏点先后出现,已知第i个坏点位置为(xi,yi),在ti时间出现.显示屏上出现一个k*k的矩阵全都是坏点时显示屏就是坏的.输出显示屏坏的时间,如果不会坏就输出- ...
- UVa 12186 Another Crisis 工人的请愿书
c表示某上司上报的最少请愿下属,k表示总下属c=0.01T*k=kT/100(0.01T*k是整数)c=[0.01T*k]+1=[kT/100]+1(0.01T*k不是整数) kT=100 c=1 k ...