技术标签: 南邮OJ
题目链接:点击打开链接
代码是借鉴别人的,链接:点击打开链接
<span style="font-size:18px;">#include <iostream>
using namespace std;
class nodeList;
class Node //单链表节点
{
private:
int coef;
int exp;
Node * link;
friend class nodeList;
friend ostream & operator << (ostream &,const Node &);
public:
Node (int c, int e):coef(c),exp(e)
{
link = 0;
}
Node (int c,int e, Node * next):coef(c),exp(e)
{
link = next;
}
Node * Insert (int c, int e)
{
link = new Node (c,e,link);
return link;
}
};
ostream & operator << (ostream & out, const Node & val)
{
if (val.coef == 1)
{
switch (val.exp)
{
case 0:out << 1;break;
case 1:out << "X";break;
default : out << "X^" << val.exp; break;
}
return out;
}
if (val.coef == -1)
{
switch (val.exp)
{
case 0:out << -1;break;
case 1:out << "-X"; break;
default : out << "-X^"<< val.exp;break;
}
return out;
}
else
{
out << val.coef;
switch (val.exp)
{
case 0:break;
case 1:out <<"X"; break;
default : out<<"X^" << val.exp;break;
}
return out;
}
}
class nodeList
{
friend ostream & operator << (ostream &, const nodeList & );
friend istream & operator >> (istream &, nodeList &);
friend nodeList & operator + (nodeList &, nodeList &);
private:
Node * theList;
public:
nodeList();
~nodeList();
void AddNode (istream & in);
void Output (ostream & out) const;
void Listadd (nodeList & r);
};
nodeList :: nodeList()
{
theList = new Node (0,-1);
theList ->link = theList;
}
nodeList::~nodeList()
{
Node * p = theList->link;
while (p != theList)
{
theList->link = p->link;
delete p;
p = theList->link;
}
delete theList;
}
void nodeList:: AddNode(istream & in)
{
Node * q = theList;
int count = 0;
int c,e;
for (;;)
{
cin >> c >>e;
if (c==0 && e ==-1)
{
break;
}
else
{
q = q->Insert(c,e);
}
count ++;
}
if (count == 0)
{
q = q->Insert(0,0);
cout << 0;
}
}
void nodeList:: Output (ostream & out )const
{
int i=0,j,k=0;
Node * m = theList->link;
for (; m!=theList & m->coef == 0;m=m->link)
{
i++;
}
m = theList->link;
for (;m!= theList; m=m->link)
{
k++;
}
m = theList->link;
if (k==1&& m->coef == 0)
{
cout << 0 << endl;
return;
}
if (k==i)
{
cout << 0<< endl;
return ;
}
for (j =0; j<i;j++)
{
m=m->link;
}
out << *m;
m=m->link;
for (;m!=theList;m=m->link)
{
if (m->coef > 0)
{
cout << "+";
out << *m;
}
else if (m->coef < 0)
{
out << *m;
}
}
cout << endl;
}
void nodeList::Listadd(nodeList & r)
{
Node * q,*q1 = theList,*p;
p = r.theList->link;
q = q1->link;
while(p->exp >= 0)
{
while (p->exp < q->exp)
{
q1=q;
q=q->link;
}
if (p->exp == q->exp)
{
q->coef = p->coef + q->coef;
if (p->coef == 0)
{
q1->link = q->link;
delete q;
q = q1->link;
}
else
{
q1=q;
q=q->link;
}
}
else
q1 = q1->Insert(p->coef,p->exp);
p=p->link;
}
}
ostream & operator <<(ostream & out, const nodeList & x)
{
x.Output(out);
return out;
}
istream & operator >> (istream & in, nodeList & x)
{
x.AddNode (in);
return in;
}
nodeList & operator + (nodeList & a, nodeList & b )
{
a.Listadd (b);
return a;
}
int main()
{
nodeList p,q,q1;
cin>>p,cout<<p;
cin>>q,cout<<q;
q1=q+p;
cout<<q1;
}</span>
文章浏览阅读3k次。Node.js使用child_process运行脚本的输入输出错误 Node.js的各类模块中,有一个child_process模块。child_process模块主要用来创建一个子进程,并通过调用命令行来运行脚本文件(本文以Python为例),通过参数的传递,来获取输出。 输入错误: 由于使用命令行运行脚本,所以脚本文件默认_reading from "node:child_process" is not handled by plugins (unhandled schem
文章浏览阅读1.6k次,点赞2次,收藏10次。matplotlib是python中强大的画图模块。首先确保已经安装python,然后用pip来安装matplotlib模块。进入到cmd窗口下,执行python -m pip install -U pip setuptools进行升级。接着键入python -m pip install matplotlib进行自动的安装,系统会自动下载安装包。安装完成后,可以用python -m pip lis..._>> require python matplotlib module >> require python scipy.stats module >>
文章浏览阅读114次。场景:开发环境:IntelliJ IDEA 2020.1 x64项目搭建:SSM,MyBatis问题描述:对于spring整合mybatis,AppliicationContext.xml有如下配置:<!--将sqlSession注入容器--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataS_ssm+mybatis idea
文章浏览阅读2.6k次,点赞5次,收藏37次。MCU免费开发环境一般芯片厂家会提供各种开发IDE方案,通常其中就包括其自家的集成IDE,如:意法半导体 STM32CubeIDENXP CodewarriorTI CCS另外也可以用eclipse、VS studio、VS code等搭建开发环境VS Code 搭建stm32开发环境1.搭建准备程序安装1.下载并安装 vs code2.下载并安装 STM32CubeMX..._code warrior vs
文章浏览阅读4.5k次。servlet做的。正好java老师上课讲了一点,回来复现了一下。实现的是从html提交表单,java收到并进行RSA加密的相关计算。重点是提醒自己的form表单里的action填写。(两个文件在同一包下)servlet_java.java文件package com.example.demo;import javax.servlet.ServletException;import ..._eclipse用户信息的提交与反馈
文章浏览阅读2k次。原文地址读取表格内容需要xlrd这个模块包的支持import xlrd# 获取表格对象xlsx = xlrd.open_workbook('data/e03.xlsx') # 打开表格# 获取sheet对象的两种方式table = xlsx.sheet_by_index(0) # 通过sheet索引获取# table = xlsx.sheet_by_name('全部付款..._pytho表格实例
文章浏览阅读71次。Java基础常见面试题总结(一)
文章浏览阅读1.3k次。Armadillo:C++下的Matlab替代品地址:http://arma.sourceforge.net/许可证:MPL 2.0目前使用比较广的C++矩阵运算库之一,是在C++下使用Matlab方式操作矩阵很好的选择,许多Matlab的矩阵操作函数都可以找到对应,这对习惯了Matlab的人来说实在是非常方便,另外如果要将Matlab下做研究的代码改写成C++,使_petsc gpu 安装
文章浏览阅读3.3k次,点赞2次,收藏21次。公司项目开发需求:将海康摄像头的rtsp流在web端及微信小程序端进行播放。之前我写过一篇关于web端使用webtrc+videojs播放rtsp流的文章,确实能够解决web端播放rtsp流的需求,但是这次多加了一个微信小程序....所以要考虑小程序的播放问题。本着探索实践的精神在网上找了一些资料,问了问GPT,最终选择自己搭建一个流媒体服务器来拉流推流。①ffmpeg拉流推流有的时候会断开,断开自动重连需要自己处理。_linux 安装nginx并配置nginx-http-flv-module
文章浏览阅读1.2k次。K8s系列之:共享存储原理一、共享存储机制概述二、PV详解1.PV的关键配置参数1)存储能力()一、共享存储机制概述K8s对于有状态的容器应用或者对数据需要持久化的应用,不仅需要将容器内的目录挂载到宿主机的目录或者emptyDir临时存储卷,而且需要更加可靠的存储来保存应用产生的重要数据,以便容器应用在重建之后,仍然可以使用之前的数据。K8s引入PersistentVolume和PersistentVolumeClaim两个资源对象来实现对存储的管理子系统。PersistentVolume(PV)是_vg-data pvc
文章浏览阅读556次。HSDE算法是2016年提出来的,是一种多突变策略和自适应调整控制参数的DE改进算法。自适应参数部分采用JADE的方式。以下是HSDE算法的函数m文件夹:%%%%%%%%%%%%%%%%%%%%%%%%HSDE算法----2015%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%文献来源:A new differential evolution algorithm with a hybrid mutation operator and self-adapting control p_hsde
文章浏览阅读1k次。腾讯二面:Redis与MySQL双写一致性如何保证?前言:四月份的时候,有位朋友去面试,他说被问到Redis与MySQL双写一致性如何保证? 这道题其实就是在问缓存和数据库在双写场景下,一致性是如何保证的?本文将跟大家一起来探讨如何回答这个问题。谈谈一致性:一致性就是数据保持一致,在分布式系统中,可以理解为多个节点中数据的值是一致的。强一致性:这种一致性级别是最符合用户直觉的,它要求系统写入什么,读出来的也会是什么,用户体验好,但实现起来往往对系统的性能影响大弱一致性:这种一致性级别约束了系_acedpostcommand命令行不回显