| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

已结贴   问题点数：20  回复次数：3

PloyIn.txt 中的数据为：
3 1 0 1 1 1 2
3 2 0 3 2 7 9
3 90 0 78 4 8 8

PloyOut.txt中数据为
3 0.000000 -1869574000
请大神帮忙看看哪里出问题了 ？

#include <stdio.h>
#include <stdlib.h>

typedef struct
{
float coef;                        /*系数*/
int expn;                         /*指数*/
}ElemType;
typedef struct LNode
{
ElemType data;
struct LNode *pNext;
}LNode, *Ploynomial;

{
printf ("************************************************************\n");
printf ("------------------------------------------------------------\n");
printf ("\t\t  多项式运算环境\t\t\n");
printf ("------------------------------------------------------------\n");
printf ("\t\t (1): 创建多项式\t\n");
printf ("\t\t (2): 打印多项式\t\n");
printf ("\t\t (3): 多项式相加\t\n");
printf ("\t\t (4): 多项式相减\t\n");
printf ("\t\t (5): 多项式相乘\t\n");
printf ("\t\t (6): 多项式混合运算\t\n");
printf ("\t\t (7): 退出多项式\t\n");
printf ("************************************************************\n");
printf ("请输入你的选择:  ");
}

void InitList (Ploynomial Ployn)
{
Ployn = (Ploynomial) malloc (sizeof (LNode));
Ployn -> pNext == NULL;
}

{
FILE *fp;
if ((fp = fopen("PloyIn.txt", "r")) == NULL)
{
printf ("错误！");
exit(0);
}
fscanf (fp, "%d", &n);
fclose (fp);
return n;
}
{
FILE *fp;
if ((fp = fopen("PloyIn.txt", "r")) == NULL)
{
printf ("无法读入文件!");
exit (0);
}
if (Ployn)
{
fscanf (fp, "%f %d ", &Ployn -> data.coef, &Ployn -> data.expn);
}
fclose (fp);
}
{
int i;
Ploynomial p;
head = (Ploynomial ) malloc (sizeof (LNode));    /*创建头结点*/
for (i = 0; i < n; i++)
{
p = (Ploynomial ) malloc (sizeof (LNode));    /*创建新结点*/
}
}
main()
{
int i,n,m, choose;
Ploynomial PloynA, PloynA1, PloynB, PloynC;
InitList (PloynA);
InitList (PloynB);
while (1)
{
scanf ("%d", &choose);
switch (choose)
{
case 1 :
{
//PloynA = (Ploynomial)malloc(sizeof(LNode));
printf ("请读入多项式A \n");
CreatePloyn (PloynA, m);
SavePloyn(  PloynA, m);
printf ("a : ");
//PrintPloyn(PloynA);
printf ("\n");
//CreatePloym(PloynA, m);
break;
}
case 2 :
{
//printf ("多项式a.  ");
//PrintPloyn(PloynA);
}
}
}
system ("pause");
}

得分:10

http://blog.yuccn. net
得分:0

谢谢
得分:10
ployout.txt是什么，全部程序没搬上来吧
• 4
• 1/1页
• 1