首页 > 试题广场 >

复数集合

[编程题]复数集合
  • 热度指数:23855 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    一个复数(x+iy)集合,两种操作作用在该集合上:     1、Pop 表示读出集合中复数模值最大的那个复数,如集合为空 输出  empty  ,不为空就输出最大的那个复数并且从集合中删除那个复数,再输出集合的大小SIZE;     2 Insert a+ib  指令(a,b表示实部和虚部),将a+ib加入到集合中 ,输出集合的大小SIZE;     最开始要读入一个int n,表示接下来的n行每一行都是一条命令。

输入描述:
输入有多组数据。
每组输入一个n(1<=n<=1000),然后再输入n条指令。


输出描述:
根据指令输出结果。

模相等的输出b较小的复数。
a和b都是非负数。
示例1

输入

3
Pop
Insert 1+i2
Pop

输出

empty
SIZE = 1
1+i2
SIZE = 0
头像 yyer
发表于 2023-02-12 17:19:34
//当涉及到多次删除等操作,还是要用队列或栈之类,而不是用vector //若对输出有自定义优先级要求,则用优先队列 #include <queue> #include <string> #include <iostream> using namespace st 展开全文
头像 哆啦A梦的百宝袋1234
发表于 2024-01-19 20:16:18
#include <bits/stdc++.h> using namespace std; struct node { int a; int b; }; bool operator<( node n1, node n2) { //n1的模小于n2的模,则交换 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-18 11:43:28
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main() { vector<str 展开全文
头像 爱读书的伊泽瑞尔很有胆量
发表于 2023-03-12 15:55:32
#include "cstdio" #include "queue" using namespace std; #include "string" struct complex{ int re; int im; }; bool operator < (complex lhs,c 展开全文
头像 上课笑醒
发表于 2023-03-25 14:32:35
主要考察了优先队列,注意优先队列的使用、运算符重载来比较结构体、添加cmath头文件、和各种细节 #include <queue> #include <cstdio> #include <iostream> #include <string> #inc 展开全文
头像 SStarry
发表于 2023-08-23 20:33:09
#include <cstdio> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; int n; 展开全文
头像 凉州词
发表于 2025-02-23 10:49:42
#include <iostream> #include <cstdio> #include <queue> #include <string> using namespace std; struct complex { int real; 展开全文
头像 理性的追梦人躺平又起来了
发表于 2023-04-03 12:47:54
#include<cstdio> #include<queue> #include<string> using namespace std; struct Complex{ int re; int im; }; bool operator < (Com 展开全文
头像 ChaChaCharis
发表于 2023-03-13 08:56:40
#include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; struct Complex{ int real; 展开全文
头像 阿尔芒a
发表于 2024-03-13 18:06:12
#include<iostream> #include<queue> #include<string> #include<cmath> using namespace std; struct complex { int shi; int fu; 展开全文

问题信息

难度:
131条回答 10617浏览

热门推荐

通过挑战的用户

查看代码
复数集合