ACM HDU 1263水果
来源:互联网 发布:asp.net与php的区别 编辑:程序博客网 时间:2024/05/01 06:07
用一个很“特别”的map,这个题目就行了;<
map可以通过键找到值,这里我们需要通过地名找到水果的种类通过水果的种类找到他的出售次数;所以这里定义一个map<string,map<string,int>>三个变量分别是地名,水果名,销售次数;
#include <iostream>#include <map>#include <string.h>#include <string>using namespace std;int main(){ int x,y; cin>>x; while (x--) { cin>>y; int count; char name[100],place[100]; map<string,map<string,int> > list; while(y--) { cin>>name>>place; cin>>count; list[place][name]+=count;//保存地名,种类,次数; } map<string,map<string,int>>::iterator it; map<string,int>::iterator it1; for(it=list.begin();it!=list.end();it++) { cout<<it->first<<endl; for (it1=(it->second).begin();it1!=(it->second).end(); it1++) { cout<<" |----"; cout<<it1->first<<'('<<it1->second<<')'<<endl; } } list.clear(); if(x!=0)cout<<endl; } return 0;}
2 0
- ACM HDU 1263水果
- hdu 1263 水果
- hdu - 1263 水果
- HDU 1263 水果
- hdu 1263 水果
- HDU 1263 水果
- 水果 hdu 1263 模拟
- HDU 1263 水果
- HDU 1263 水果
- hdu 1263 水果
- HDU 1263 水果
- hdu 1263 水果
- hdu 1263 水果
- hdu 1263 水果
- hdu 1263 水果
- hdu 1263 水果
- HDU 1263 水果
- HDU 1263 水果
- 表单提交后分页页面标签POST实现 —— 一个小小的bug引发的思考
- 蓝桥杯 摆动问题 dp和dfs,这个是dp做的
- android下载, 断点续传, 在关闭activity或杀进程后,可继续下载,保证android下载速度
- DSP移植-全局阈值分割
- 搜索引擎选择: Elasticsearch与Solr
- ACM HDU 1263水果
- Linux_Linux命令_wc_统计命令_Word Count
- 声明JavaScript函数的六种方法
- HDOJ 1242 Rescue(优先队列+BFS)
- 扩展欧几里得原理与模板
- Gaussian Blurring
- H.264中整数DCT变换,量化,反量化,反DCT究竟是如何实现的?(无代码,无真相)
- 关于main(int argc, char* argv[])
- 新浪SAE启动报class org.springframework.web.filter.CharacterEncodingFilter is not a javax.servlet.Filter