算法笔记上能踩的坑都踩了。

#include<iostream>
using namespace std;
float a[1001];//至少1000个位置
int main(){
int n,cnt=0,aa;
float bb;
cin>>n;
for(int i=0;i<n;i++){
cin>>aa>>bb;
if(a[aa]==0)cnt++;
a[aa]+=bb;
}
cin>>n;
for(int i=0;i<n;i++){
cin>>aa>>bb;
if(a[aa]==0)cnt++;
a[aa]+=bb;
if(a[aa]==0)cnt--;//考虑会不会被抵消
}
cout<<cnt;//这里少输出一个“ ”
for(int i=1000;i>=0;i--){
if(a[i]!=0){
printf(" %d %.1f",i,a[i]);//这里都是 “ ”+i+a[i]不就没有格式错误了嘛,太死脑筋了
}
}
}

  

1002 A+B for Polynomials (25分) 格式错误的更多相关文章

  1. PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642 题目描述: This time, you are suppos ...

  2. PAT 1002 A+B for Polynomials (25分)

    题目 This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: E ...

  3. 1002 A+B for Polynomials (25分)

    This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each ...

  4. PAT Advanced 1002 A+B for Polynomials (25 分)(隐藏条件,多项式的系数不能为0)

    This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each ...

  5. 【PAT甲级】1002 A+B for Polynomials (25 分)

    题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数. AAAAAccepted code: #include<bits/stdc++.h> usin ...

  6. P1002 A+B for Polynomials (25分)

    1002 A+B for Polynomials (25分)   This time, you are supposed to find A+B where A and B are two polyn ...

  7. PAT 1009 Product of Polynomials (25分) 指数做数组下标,系数做值

    题目 This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: E ...

  8. PAT甲级 1002 A+B for Polynomials (25)(25 分)

    1002 A+B for Polynomials (25)(25 分) This time, you are supposed to find A+B where A and B are two po ...

  9. PAT 1002. A+B for Polynomials (25) 简单模拟

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

随机推荐

  1. Binding(五):多路绑定

    Binding不止能绑定一个源,它还能绑定多个源,这就是我们这节要讲的多路绑定:MultiBinding. 使用多路绑定跟一般的绑定还是有区别的,首先它并不能很好的在标记扩展中使用,另外,使用多路绑定 ...

  2. SpringBoot:springboot整合eureka报错 Unable to start embedded Tomcat

    报错信息: org.springframework.context.ApplicationContextException: Unable to start web server; nested ex ...

  3. linux学习之路第九天(磁盘分区,挂载详解)

    磁盘分区,挂载 -----分区基础知识 分区的方式 1)mbr分区: 1.最多支持四个主分区 2.系统只能安装在主分区 3.扩展分区要占一个主分区 4.mbr最大只支持2TB,但拥有最好的兼容性 -- ...

  4. 《PHP扩展学习系列》系列分享专栏

    <PHP扩展学习系列>系列分享专栏   <PHP扩展学习系列>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read/20177 ...

  5. FastTunnel-开源内网穿透框架

    FastTunnel - 打造人人都能搭建的内网穿透工具 FastTunnel是用.net core开发的一款跨平台内网穿透工具,它可以实现将内网服务暴露到公网供自己或任何人访问. 与其他穿透工具不同 ...

  6. asp.net mvc中的安全性

    1.重复提交攻击:通过Bind特性指定要绑定和不绑定的值. 2.Cookie盗窃:阻止脚本对站点中Cookie的访问,webconfig文件中添加<HttpCookies domain=&quo ...

  7. 【剑指offer】03.数组中重复的数组

    剑指 Offer 03. 数组中重复的数字 知识点:数组:哈希表:萝卜占坑思想 题目描述 找出数组中重复的数字. 在一个长度为 n 的数组 nums 里的所有数字都在 0-n-1 的范围内.数组中某些 ...

  8. 前端早读课:JavaScript函数的6个基本术语

    lambdas(匿名函数) 箭头函数. const lambda = (a, b) => a + b; first-class functions(头等函数) 该类型可以用作变量的值. docu ...

  9. 微信小程序云开发-云存储的应用-识别营业执照

    一.准备工作 1.创建云函数identify 二.云函数identify中index.js代码 1 // 云函数入口文件 2 const cloud = require('wx-server-sdk' ...

  10. 微信小程序云开发-云存储-上传单个视频到云存储并显示到页面上

    一.wxml文件 <!-- 上传视频到云存储 --> <button bindtap="chooseVideo" type="primary" ...