108. 虚数
来源:互联网 发布:!在c语言中是什么意思 编辑:程序博客网 时间:2024/05/17 01:17
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct Node{
int a; // 实部
int b; // 虚部
int m; // 模
}f[101];
bool cmp(Node a,Node b){ // 对模从小到大排序
return a.m<b.m;
}
int main()
{
int t;
while(scanf("%d",&t)!=EOF){
while(t--){
int n;
scanf("%d",&n);
int size=0;
while(n--){
char s[100];
scanf("%s",s);
if(s[0]=='P'){
if(size==0) printf("Empty!\n");
else{
printf("%d+i%d\n",f[size].a,f[size].b);
size--;
if(size==0) printf("Empty!\n");
else printf("Size: %d\n",size);
}
}else if(s[0]=='I'){
size++;
scanf("%d+i%d",&f[size].a,&f[size].b);
f[size].m=f[size].a*f[size].a+f[size].b*f[size].b;
sort(f+1,f+size+1,cmp);
printf("Size: %d\n",size);
}
}
}
}
return 0;
}
#include<string.h>
#include<algorithm>
using namespace std;
struct Node{
int a; // 实部
int b; // 虚部
int m; // 模
}f[101];
bool cmp(Node a,Node b){ // 对模从小到大排序
return a.m<b.m;
}
int main()
{
int t;
while(scanf("%d",&t)!=EOF){
while(t--){
int n;
scanf("%d",&n);
int size=0;
while(n--){
char s[100];
scanf("%s",s);
if(s[0]=='P'){
if(size==0) printf("Empty!\n");
else{
printf("%d+i%d\n",f[size].a,f[size].b);
size--;
if(size==0) printf("Empty!\n");
else printf("Size: %d\n",size);
}
}else if(s[0]=='I'){
size++;
scanf("%d+i%d",&f[size].a,&f[size].b);
f[size].m=f[size].a*f[size].a+f[size].b*f[size].b;
sort(f+1,f+size+1,cmp);
printf("Size: %d\n",size);
}
}
}
}
return 0;
}
0 0
- 108. 虚数
- 虚数
- 虚数
- 北邮OJ-108. 虚数-11网研上机B
- 实数 虚数
- 虚数的意义,虚数到底是什么
- 虚数的加法运算
- 虚数的理解
- 虚数的意义
- 虚数的意义
- 虚数的意义
- 虚数的意义
- 虚数 计算圆形面积
- 虚数的意义
- 虚数的意义
- 北邮OJ 108 虚数
- 虚数的几何意义
- C语言中的虚数
- Struts1基本运作流程
- DruidConnectionProvider失效在hibernate3.6.10
- 【框架-MFC】MFC 所有Combox失效,无法下拉
- Hibernate的缓存
- 常用正则表达式
- 108. 虚数
- IOS设备之armv6,armv7,armv7s,arm64
- struts2 tags - s:property 显示变量
- 3月底工作安排
- 关于使用bean:write标签显示html内容
- Linux系列:Fedora虚拟机设置固定IP上网(配置IP、网关、DNS、防止resolv.conf被重写)
- chkconfig用法
- 中国天气网城市代码
- 记录一下sql中使用游标循环读取数据操作