合并表记录
来源:互联网 发布:模拟退火算法伪代码 编辑:程序博客网 时间:2024/05/21 06:43
数据表记录包含表索引和数值,请对表索引相同的记录进行合并,即将相同索引的数值进行求和运算,输出按照key值升序进行输出。
#include<iostream>
#include<map>
using namespace std;
int
main(){
int
n;
map<
int
,
int
> m;
cin>>n;
while
(n--){
int
key,value;
cin>>key>>value;
if
(!m[key])
m[key]=value;
else
m[key]+=value;
}
for
(map<
int
,
int
>::iterator it=m.begin();it!=m.end();++it)
cout<<it->first<<
' '
<<it->second<<endl;
return
0
;
}
0 0
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 009-合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 合并表记录
- 字符编码笔记:ASCII,Unicode和UTF-8
- Html文件打开中文出现乱码
- Spring MVC form表单post提交出现乱码
- Linux netstat命令详解
- 提取不重复的整数
- 合并表记录
- jieba安装
- atom修改字体大小
- TensorFlow安装入门图文教程
- 取近似值
- 数据的准确性对模型效果的重要性
- org.springframework.beans.factory.BeanDefinitionStoreException:
- 质数因子
- 源码解析之 HashMap与HashTable的区别