求编程高手帮做一个程序!!

作者&投稿:浑连 (若有异议请与网页底部的电邮联系)
求编程高手帮我编一个简单的程序~

好了 你接收一下

用EXCEL编写一下即可。

/*这是第二个题的。应该欧可!自己研究研究*/

#include <iostream.h>
#include <stdlib.h>
//using namespace std;

struct Term{ //多项式的项结点
Term(int c,int e):coef(c),exp(e){link = NULL;} //构造函数1
Term(int c,int e,Term* next):coef(c),exp(e){link = next;}//构造函数2
Term * InsertAfter(int c,int e);//构造一个新项<c,e>结点,插在*this及其后继间
int coef;
int exp;
Term *link;
};

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

Term* Term::InsertAfter(int c,int e)
{
link = new Term(c,e,link);//构建新项结点<c,e>,插在当前结点及其后继结点间
return link; //函数返回值为新项结点的地址
}

class Ploynominal //多项式类
{
public:
Ploynominal();//构造只有表头结点的单循环链表
// ~Ploynominal();//释放多项式的各结点空间
void AddTerms(istream& in);
void Output(ostream& out)const;
void PolyAdd(const Ploynominal&r, const Ploynominal&m);
void PolyMuti(const Ploynominal&r,const Ploynominal&s,Ploynominal c[],Ploynominal e[]);
Ploynominal& operator+(const Ploynominal& b);
void operator=(const Ploynominal& x);
private:
Term *theList;//带头结点单循环链表存储一个多项式
int n;
friend ostream& operator<<(ostream&,const Ploynominal&);
friend istream& operator>>(istream&,Ploynominal&);
};
Ploynominal::Ploynominal()
{
theList = new Term(0,-1); //带头结点的空单循环链表
theList->link = theList;
n = 0;
}

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

void Ploynominal::Output(ostream& out) const
{
bool start = true;
Term *p = theList->link;
out<<"The ploynominal is :\n"<<endl;
for(;p!=theList;p = p->link){
if(!start&&p->coef>0) out<<'+';
start = false;
out<<*p;
}
out<<endl;
}

istream& operator>>(istream&in, Ploynominal& ploy)
{
ploy.AddTerms(in);
return in;
}

ostream& operator<<(ostream&out,const Ploynominal& ploy)
{
ploy.Output(out);
return out;
}

int ExpComp(int x,int y)
{
if(x == y) return 0;
else if(x > y) return 1;
else return -1;
}

void Ploynominal::PolyAdd(const Ploynominal&r,const Ploynominal&m)
{
if (r.theList->link == r.theList)
return;
Term *q,*preq,*q2,*p,*w;//preq是q的前驱结点
preq = m.theList,q = m.theList->link;
p = r.theList->link;
w = theList;
while(p->exp>=0)
{
int a1,a2; //Term *g= w;
switch(ExpComp(p->exp,q->exp))
{
case -1:w= w->InsertAfter(q->coef,q->exp);preq = q;q = q->link;break;
case 0:

a1 = q->coef + p->coef;
a2 = q->exp;
if(a1 == 0)
{
q2 = q;
preq->link = q->link;
q = q->link;
p = p->link;
delete(q2);
}
else {
w = w->InsertAfter(a1,a2);
preq = q;q = q->link;p=p->link;
}
break;
case 1:
w= w->InsertAfter(p->coef,p->exp);
p = p->link;break;
}
}

}

void Ploynominal::PolyMuti(const Ploynominal&r,const Ploynominal&s, Ploynominal c[],Ploynominal e[])
{
Term *q,*q1,*prep,*prep2[10];
prep = r.theList;
q = r.theList->link;
q1 = s.theList->link;
for (int k=0;k<10;k++)
prep2[k] = c[k].theList;
int m =0;
int j,count=0;
if (r.n>s.n)
{
j = r.n;
}
else
{
j = s.n;
}
if (j==r.n)
{
while (q1!=s.theList)
{
for (int i=0;i<j;i++)
{
prep2[m] = prep2[m]->InsertAfter(q->coef*q1->coef,q->exp+q1->exp);
q = q->link;
}
q1 = q1->link;
q = q->link;
m++;
}
}
else
{
while (q!=r.theList)
{
for (int i=0;i<j;i++)
{
prep2[m] = prep2[m]->InsertAfter(q->coef*q1->coef,q->exp+q1->exp);
q1=q1->link;
}
q = q->link;
q1 = q1->link;
m++;
}
}
if (m==1)
cout <<c[0];
else
{
int l = 1;
e[0].PolyAdd(c[1],c[0]);
for (int i=2;i<=m;i++)
{
int k = 0;
e[l].PolyAdd(c[i],e[l-1]);
l++;
}
cout<<"两个多项式的积为:"<<e[l-2]<<endl;
}
}

int main(int argc, char *argv[])
{
Ploynominal a,b,c[10],d,e[10],f;
cout<<"输入第一个多项式:"<<endl;
cin>>a;
cout<<"输入第二个多项式:"<<endl;
cin>>b;
d.PolyMuti(a,b,c,e);
system("PAUSE");
return 0;
}

这不叫程序,这叫一个项目,一个系统。不是一天两天能完成的大作业。


求c语言或c++编程高手帮忙
不知道你要的是什么程序,简单的就是用switch语句就OK了 include<stdio.h> void main(){ int money;printf("请投币:\\n");scanf("%d",&money);switch(money){ case 1:printf("洗衣机执行15分钟的脱水功能!\\n");break;case 2:printf("洗衣机执行30分钟的水洗和脱水功能!\\n");break;case...

各位高手帮帮忙,帮我做个C语言编程
二楼第二个求的有错 12366 99 15 include <stdio.h> int count();\/\/第二个问题 int fun3();\/\/第三个问题 int isSushu(int k);void main(){ int i,record;double s=0;for(i=1;;i++){ s+=1.0\/i;if(s>10)break;else record=i;} printf("%d\\n",record);printf("%d\\n",...

c语言编程题,请高手帮忙做一下,拜谢,急急急急……
\/\/ 函数定义,不用太多解释了吧?一个循环解决正数值的累加,另一个是负数值的累加。\/\/ double funcPi( int n ){ double back = 0.0;int count;for (count = 1; count <= 4*n-1; count+=4){ back += (double)1\/count;} for (count = 3; count <= 4*n-1; count+=4){ b...

请高手帮我编程C语言啊...谢了啊
%d",&i);printf("学号%d 分数%f\\n",stu[i-1].num,stu[i-1].score);} break;case 2:;break;default :printf("?输入出错?\\n");break;} }} 声明:本程序编写了成绩录入和成绩查询功能,成绩计算等功能不知道具体要求,请自行完善;希望对你有用!参考资料:C程序设计 谭浩强老师版 ...

C语言程序设计 编程,我是C语言初学者,请高手们帮我为下面这道题编个程 ...
include <stdio.h> int main(){ char c;int x = 0, y = 0;printf("***请按提示选择***\\n");printf("a---本校全日制学生\\n");printf("b---本校夜大学生\\n");printf("c---外校学生\\n");scanf("%c", &c);if(c == 'a'){ printf("你是本校全日制学生,不收付费 ^_...

...能给我一个两个50位以下的两个数的加法程序,跪求编程高手帮忙...
include<stdio.h> include<string.h> int main(){ int i,t,j=1,n,len,k;char sum[1009],sa[1009],sb[1009];for(i=0;i<1009;i++)sum[i]='0';scanf("%s%s",sa,sb);len=strlen(sa);for(i=len-1,k=0;i>=0;i--,k++){ sum[k]=sum[k]-'0'+sa[i];n=k;while(sum...

急!请C++高手帮忙编程。100分送上。
\/*(1)定义一个函数 int count(int a[],int n) 在n个元素的数组a中,统计出大于零的元素个数,此个数作为函数返回值。 在main()函数中,对数组b做如下初始化 int b[]={15,16,-23,7,-5,19,-2,0,28,11};然后调用你定义的函数,在主函数中输出数组b中小于零元素的个数。\/ include...

C#求高手帮忙编程序。
第一个问题:这个用textbox中的PasswordChar属性。首先在textbox属性栏中将PasswordChar属性改为“*”然后在button下添加如下代码:string a; a = textBox1.Text; textBox1.PasswordChar = '\\0'; textBox1.Text = a;有图有真相:问题二没看懂,你的意思是字符串是自动添加到listbox中么?

高分求单片机高手帮写一段简单的C51程序
define uint unsigned int define uchar unsigned char uchar Receive_Buffer[6];uchar Buf_Index = 0;uchar Time_cnt=0;uchar DRV_OUT=0;sbit val_out=P1^0;uchar code DSY_CODE[]= { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00 };sbit d1=P3^3;sbit d2=P3^4...

C语言编程题: 随便编一个程序解决任意实际问题,要求至少调用4个函数...
dis_smg[1]=duanma[miao\/10];dis_smg[2]=duanma[fen%10]|0x80;dis_smg[3]=duanma[fen\/10];dis_smg[4]=duanma[shi%10]|0x80;dis_smg[5]=duanma[shi\/10];} void display(){ uchar i;for(i=0;i<6;i++){ dula=1;P0=0x00;dula=0;wela=1;P0=weima[i];wela=0;dula=1...

甘德县15684835074: 编程高手请帮忙编写一个程序! -
师金溶芯: #includevoid main() { int num; printf("请输入数字:"); scanf("%d",&num); printf("%d只青蛙就%d个头,%d只眼睛%d条腿.呱呱呱呱呱呱 呱呱呱呱呱呱 呱呱呱呱呱呱呱!", num,num,2*num,4*num); }

甘德县15684835074: 求高手帮忙编写程序
师金溶芯: #include<algorithm>#include<stdio.h>#include<string.h> int main(){ int l; char s[1000]; scanf("%s",s); l=strlen(s); sort(s,s+l); printf("%s\n",s); return 0;} 本人口口510685263

甘德县15684835074: 哪位编程高手能帮我编个小的程序啊 具体内容见下...
师金溶芯: 哎,失恋了睡不着,帮你写了吧.用数组做的,你直接复制我运行过.额你学c的话别用tc工具了不支持汉语而且用起来也麻烦,你用c-free吧,网上找下破解版没有的话我发给你.下面是代码. #include<iostream.h> int max(int a[]); int min(int a[])...

甘德县15684835074: 50分紧急求助!!!(求助互联网编程的高手,帮忙编写个程序) -
师金溶芯: 设定用户名的textbox控件的id是uname,密码是pwd 提示的label控件的id为t myuser里的user_info表里有两个字段uname,pwd.连接数据库自己写 cmd,conn自己补上去 核心代码如下:cmd.CommandText="select count(*) from user_info where ...

甘德县15684835074: 哪位编程高手帮我写一个这样的程序啊?急啊!!!先谢谢啦!
师金溶芯: #include <stdio.h> void add1(int sum) { sum=0; int a; while(1) { scanf("%d",&a); sum+=a; if(a==0) break; } } void add2(int *sum) { *sum=0; int a; while(1) { scanf("%d",&a); *sum+=a; if(a==0) break; } } void add3(int &sum) { sum=0; int a; while(1) { ...

甘德县15684835074: 求电脑编程高手帮助!编一个很简单的程序 -
师金溶芯: 用EXCEL编写一下即可.

甘德县15684835074: 哪位编程高手帮我编写一个小程序,要求C语言,谢谢了
师金溶芯: #include <stdio.h> void main() { printf("Hello World!"); }

甘德县15684835074: 求编程高手,帮我写一个简单的程序,是老师布置的作业
师金溶芯: 用无限循环和break就可以了. 我举个例子吧, 比如 for( ;;) { scanf("%d",&a); if(a<0) break; } 这个解决了, 程序应该就很快可以做出来了吧. 建议你用数组做.

甘德县15684835074: 请高手帮忙编个程序,谢谢
师金溶芯: 因为涉及到怎么置光标位置的问题,现在还做不出来,下面的程序是c++的,你看一下他是输入粘合月求一个月的日历,我再用C试一下 //输入年月求该月日历 #include <iostream> #include <iomanip> using namespace std; class calendarType { ...

甘德县15684835074: 请高手帮我用C语言编一个程序
师金溶芯: 第一,先输入scanf("%s",strS); 第二,循环判断这个字符串中是否有数字并存入date[] j=0; for(i=0;i<strlen(strS);i++) { if(strS[i]>='0'&&strS[i]<='9') { date[j]=strS[i]-'0'; j=j+1; } } 第三、打印出date for(i=0;i<j;i++) { printf("date[%d]=%d\n",i,date[i]); } 第四、为date排列顺序

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网