这个程序出现这样的窗口是什么意思?

qinken547 2010-03-21 11:30:02
#ifndef POLYNOMINAL_H_
#define POLYNOMINAL_H_

#include <iostream>
class Term{
public:
Term(int c,int e);
Term(int c,int e,Term* nxt);
Term* InsertAfter(int c,int e);
private:
int coef;
int exp;
Term* link;
friend std::ostream& operator<<(std::ostream& ,const Term&);
friend class Polynominal;
};



class Polynominal
{
public:
Polynominal();
~Polynominal();
void AddTerms(std::istream &in);
void Output(std::ostream &out)const;
void PolyAdd(Polynominal& r);
private:
Term* theList;
friend std::ostream& operator <<(std::ostream &,const Polynominal &);
friend std::iostream &operator >>(std::iostream &,Polynominal &);
friend Polynominal& operator +(Polynominal &,Polynominal &);
};



Term::Term(int c,int e):coef(c),exp(e)
{
link=0;
}

Term::Term(int c,int e,Term *nxt):coef(c),exp(e)
{
link=nxt;
}

Term* Term::InsertAfter(int c,int e)
{
link=new Term(c,e,link);
return link;
}

std::ostream& operator <<(std::ostream &out,const Term &val)
{
if (val.coef==0)return out;
out<<val.coef;
switch (val.exp){
case 0:break;
case 1:out<<"X";break;
default:out<<"X^"<<val.exp;break;
}
return out;
}



Polynominal::Polynominal()
{
theList=new Term(0,-1);
theList->link=theList;
}

Polynominal::~Polynominal()
{
Term *p=theList->link;
while (p!=theList){
theList->link=p->link;
delete p;
p=theList->link;
}
delete theList;
}

void Polynominal::AddTerms(std::istream &in)
{
Term *q=theList;
int c,e;
for (;;){
std::cout<<"Input a term(coef,exp):\n"<<std::endl;
std::cin>>c>>e;
if (e<0)break;
q=q->InsertAfter(c,e);
}
}

void Polynominal::Output(std::ostream &out)const
{
int first=1;Term *p=theList->link;
std::cout<<"The polynomina is:\n"<<std::endl;
for (;p!=theList;p=p->link){
if (!first&&(p->coef>0))out<<"+";
first=0;
out<<*p;
}
std::cout<<"\n"<<std::endl;
}

void Polynominal::PolyAdd(Polynominal &r)
{
Term *q,*ql=theList,*p;
p=r.theList->link;
q=ql->link;
while (p->exp>=0){
while (p->exp<q->exp){
ql=q;q=q->link;
}
if (p->exp==q->exp){
q->coef=q->coef+p->coef;
if (q->coef==0)
{
ql->link=q->link;delete (q);
q=ql->link;
}
else
{
ql=q;q=q->link;
}
}
else
ql=ql->InsertAfter(p->coef,p->exp);
p=p->link;
}
}

std::ostream &operator <<(std::ostream &out,const Polynominal& x)
{
x.Output(out);
return out;
}

std::istream &operator >>(std::istream &in,Polynominal &x)
{
x.AddTerms(in);return in;
}

Polynominal &operator +(Polynominal &a,Polynominal &b)
{
a.PolyAdd(b);return a;
}


#endif


#include "Polynominal.h"


int main()
{
Polynominal p,q;
std::cin>>p;std::cout<<p;
std::cin>>q;std::cout<<q;
q=q+p;std::cout<<q;

return 0;
}



这是人民邮电教材《数据结构》使用C++语言描述这本书中的一个程序....
我运行的时候出出了这个:
'"D:\c++\Polynominal\Debug\Polynominal.exe"' is not recognized as an internal or
external command,
operable program or batch file.
Press any key to continue . . .
...全文
58 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
liushun8910 2010-04-08
  • 打赏
  • 举报
回复
全放在一个类,不要分成几个头文件

64,651

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧