无主之地1
来源:互联网 发布:ecshop源码分析 编辑:程序博客网 时间:2024/04/28 13:04
#include<stdio.h>
struct {
int first;
int second;
}content[100];
inline void setConValue(int index, int first, int second){
content[index].first = first;
content[index].second = second;
}
int main(){
int first,second;//input
int capacity = 0; //current
int current_deal;
while(scanf("%d %d",&first,&second)){
if(!first&&!second) break;
if(!capacity){
setConValue(capacity++, first, second);
continue;
}
for(current_deal = 0; current_deal < capacity; current_deal++){
if(content[current_deal].first == first){
content[current_deal].second += second;
break;
}
}
if(current_deal == capacity)
setConValue(capacity++, first, second);
}
printf("%d %d\n",content[current_deal].first, content[current_deal].second);
}
return 0;
}
struct {
int first;
int second;
}content[100];
inline void setConValue(int index, int first, int second){
content[index].first = first;
content[index].second = second;
}
int main(){
int first,second;//input
int capacity = 0; //current
int current_deal;
while(scanf("%d %d",&first,&second)){
if(!first&&!second) break;
if(!capacity){
setConValue(capacity++, first, second);
continue;
}
for(current_deal = 0; current_deal < capacity; current_deal++){
if(content[current_deal].first == first){
content[current_deal].second += second;
break;
}
}
if(current_deal == capacity)
setConValue(capacity++, first, second);
}
//output results
for(current_deal = 0;current_deal < capacity;current_deal++){printf("%d %d\n",content[current_deal].first, content[current_deal].second);
}
return 0;
}
0 0
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- 无主之地1
- NYOJ845无主之地1
- 845 无主之地1
- nyoj845无主之地1
- nyoj-无主之地1
- nyoj845 无主之地1
- 65.无主之地1
- NYOJ845 - 无主之地1
- NYOJ 无主之地1
- 《Autotools - GNU Autoconf, Automake与Libtool实践者指南》第一章<GNU Autotools简要介绍>
- 《Autotools - GNU Autoconf, Automake与Libtool实践者指南》第二章<理解GNU编码标准>
- 《Autotools - GNU Autoconf, Automake与Libtool实践者指南》第三章<用Autoconf配置你的项目>
- POJ 2376 Cleaning Shifts(区间覆盖问题)
- 已知两个链表 la和 lb,其元素值递增排序。编程将la和lb合并成一个递减有序(相同值元素只保留一个)的链表lc。(北方名校经典试题) 本题选做
- 无主之地1
- 深入理解http
- 程序员在互联网公司和行业软件公司工作,有什么区别?
- ocp-v13-071
- PowerShell 变量(Variable)
- ocp-v13-072
- ocp-v13-073
- ocp-v13-074
- OpenCL C Built-IN Functions