pat1002
2015-05-09 15:24
155 查看
http://www.patest.cn/contests/pat-a-practise/1002
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
double zhishu[1001];
int main()
{
// freopen("C:\\1.txt","r",stdin);
// freopen("C:\\2.txt","w",stdout);
int n;
cin>>n;
while(n--)
{
int zs;
double xs;
cin>>zs>>xs;
zhishu[zs]+=xs;
}
cin>>n;
while(n--)
{
int zs;
double xs;
cin>>zs>>xs;
zhishu[zs]+=xs;
}
int i;
int cnt=0;
for(i=1000;i>=0;i--)
{
if(zhishu[i])
cnt++;
}
printf("%d",cnt);
for(i=1000;i>=0;i--)
{
if(zhishu[i])
printf(" %d %.1lf",i,zhishu[i]);
}
printf("\n");
return 0;
}
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
double zhishu[1001];
int main()
{
// freopen("C:\\1.txt","r",stdin);
// freopen("C:\\2.txt","w",stdout);
int n;
cin>>n;
while(n--)
{
int zs;
double xs;
cin>>zs>>xs;
zhishu[zs]+=xs;
}
cin>>n;
while(n--)
{
int zs;
double xs;
cin>>zs>>xs;
zhishu[zs]+=xs;
}
int i;
int cnt=0;
for(i=1000;i>=0;i--)
{
if(zhishu[i])
cnt++;
}
printf("%d",cnt);
for(i=1000;i>=0;i--)
{
if(zhishu[i])
printf(" %d %.1lf",i,zhishu[i]);
}
printf("\n");
return 0;
}
相关文章推荐
- PAT basic 1002 : 写出这个数
- PAT乙级1002
- PAT1002 写出这个数
- PAT 1002
- PAT甲级1002
- pat乙级1002
- pat 甲1002. A+B for Polynomials(map)
- PAT1002题解
- PAT (Advanced Level) Practise 1002 A+B for Polynomials (25)
- 1002 写出这个数 PAT
- PAT乙级 1002. 写出这个数 (20)
- 【PAT 1002 All Roads Lead to Rome】+ dfs + dijkstra
- 【PAT】 1002. 写出这个数 (20)
- 从今天开始刷各类题------PAT乙级----1002
- pat 乙级 1002. 写出这个数 (20)
- PAT 1002. 写出这个数 (20)【逆序输出&&转化】
- PAT(乙) 1002.写出这个数 (20)
- PAT 1002. 写出这个数 (20)
- PAT 1002. 写出这个数
- PAT_1002