程序提示出现error C2078: too many initializers是为什么?怎么改?
的有关信息介绍如下:
#includeint main(){char diamond[][5]={{' ',' ','*'},{' ','*',' ','*'},{'*',' ',' ',' ',' ','*'},{' ','*',' ','*'},{' ',' ','*'}};int i,j;沪常高毁清端薨得胳全供户for(i=0;i<5;i++){for(j=0;j<5;j++)printf("%c",diamond[i][j]);printf("\n");}return 0;}按教材上输入岩陆的纤枣前 怎么会有错误那,求教我代码我新手问题应该挺简单求帮忙定采纳谢谢各位神!#include#includeusing namespace std;struct Node{double coef;int expn;Node *next;};class poly{public:void pol(double a[],int b[],int n);void print();void plus(poly& B);void minus(poly& B);double value(double x);Node *f;//第条链表指针};void poly::print(){//输链表元素Node *p = f->next;while(p!=NULL){cout<coef<<"\t"<expn<<"\t";p = p->next;}cout<next = NULL;Node* r = f;for(int i=0;icoef = a[i];s->expn = b[i];s->next = NULL;r->next = s;r = s;}}void poly::plus(poly& B)//两项式相加{Node *p = f;Node *p_prior = NULL;Node *q = B.f;Node *q_prior = NULL;while(p&&q){if(p->expnexpn){p_prior=p;p=p->next;}else if(p->expn>q->expn){p_prior->next = q;p_prior = q;q = q->next;p_prior->next = p;}else if(p->expn==q->expn){p->coef = p->coef + q->coef;if(fabs(p->coef)<1e-7){p_prior->next = p->next;delete p;p=p_prior->next;}else{p_prior = p;p = p_prior->next;}}}if(q)p_prior->next = q;}void main(){double a1[3]={1.2, 2.4, 3};int b1[3]={1,2,5};double a2[4]={1.2, -2.4, 3,4.2};int b2[4]={1,2,3,5};poly po1(a1,b1,3); //我想调用polyclass面pol函数我写pol真(po1新建东西名称)poly po2(a2,b2,4); po1.plus(po2);po1.print();}
版权声明:文章由 好百科 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.haobaik.com/article/232858.html