⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jisuanfangfa.c

📁 计算方法中的根据给出的一组数值(x,y)构造出相应的方程
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <bios.h>
#include <dos.h>
#include <math.h>
#include <string.h>

typedef struct internodes{
    char x[15];
    char y[15];
    float Li;
    struct internodes * next;
    }Iternodes;

void qinping ( )
 {
   window ( 1, 1, 80, 25 );
   textbackground ( GREEN );
   textcolor ( WHITE );
   clrscr ( );
 }

void shezhi1(int x1,int y1,int x2,int y2,int bcolor,int fcolor,char *string)
 {
     window(x1,y1,x2,y2);
     textbackground(bcolor);
     textcolor(fcolor);
     clrscr();
     gets(string);
     window(1,1,80,25);
}

void huakuang(int n)
{
  int i,j;
  qinping();
  gotoxy(25,6);
  printf("THE RESULT OF THE STRUCTTURE");
  for(i=1;i<=(n/2+1)*10;i++)
    for(j=8;j<15;j+=2)
  {
    gotoxy(i,j);putch(0xcd);
  }
  for(i=10;i<=(n/2+1)*10;i+=10)
   for(j=9;j<14;j++)
    {gotoxy(i,j);putch(0xba);}
   for(j=9;j<14;j++)
    {gotoxy(1,j);putch(0xba);}
  gotoxy(1,8);putch(0xc9);
  gotoxy(1,14);putch(0xc8);
  gotoxy((n/2+1)*10,8);putch(0xbb);
  gotoxy((n/2+1)*10,14);putch(0xbc);
  gotoxy(1,12);putch(0xcc);
  gotoxy((n/2+1)*10,12);putch(0xb9);
  gotoxy(1,10);putch(0xcc);
  gotoxy((n/2+1)*10,10);putch(0xb9);
  for(i=10;i<(n/2+1)*10;i+=10)
  {
    gotoxy(i,8);putch(0xcb);
    gotoxy(i,10);putch(0xce);
    gotoxy(i,12);putch(0xce);
    gotoxy(i,14);putch(0xca);
  }
}

void xianshi(struct internodes *p,int n)
{
  int i,j,k=0;
  qinping();
  gotoxy(6,2);
  printf("The details of the method of culculating common element.\n\n");
  while(p)
  {
    printf("L%d=",k);
    for(j=0;j<n/2;j++)
    {
      if(j==0)
       printf("(");
      if(j!=k)
       printf("(x-x%d)*",j);
    }
    for(i=0;i<n/2;i++)
    {
      if(i==0)
        printf(")/(");
      if(i!=k)
        printf("(x%d-x%d)",k,i);
      if(i==n/2-1)
        printf(") =%f      y%d=%f\n\n",(*p).Li,k,atof((*p).y));
    }
    p=p->next;
    k++;
  }
  printf("P%d(x)=",n/2-1);
  for(i=0;i<n/2;i++)
  {
    printf("y%d*L%d(x)+",i,i);
    if(i==n/2-1)
      printf("y%d*L%d(x)",i,i);
  }
  getch();
}
void main ()
{
  int i,j,n;
  float sum=0.0,X0,m=1.0,n1=1.0;
  char * a;
  struct internodes *head=NULL,*p,*q,*q1,*q2;
  qinping();
  printf("   This is a mathod using to solve the problebms of constructing a function.");
  printf("\n\nInput the total numbers of the internodes:");
  scanf("%d",&n);
  getchar();
  for(j=5,i=0;i<n/2;i++,j+=3)
  {
    p=(struct internodes *)malloc(sizeof(struct internodes));
    (*p).Li=1.0;
    gotoxy(10,j);cprintf("x:");
    shezhi1(15,j,30,j+1,1,7,(*p).x);
    gotoxy(40,j);cprintf("y:");
    shezhi1(45,j,60,j+1,1,7,(*p).y);
    p->next=head;
    head=p;
  }
  qinping ( );
  gotoxy(10,5);
  printf("Input the number due to be worked on:");
  scanf("%f",&X0);
  for(q1=head;q1!=NULL;q1=q1->next)
  {
    for(q2=head;q2!=NULL;q2=q2->next)
    {
      if(q2!=q1)
      {
        m*=(X0-atof((*q2).x));
        n1*=(atof((*q1).x)-atof((*q2).x));}
     }
    (*q1).Li=(float)(m/n1);
    m=1.0;n1=1.0;
  }

 xianshi(head,n);
 huakuang(n);
 gotoxy(3,9);printf("x");
 gotoxy(3,11); printf("y");
 gotoxy(3,13); printf("Li");
 for(q=head,i=11;q!=NULL;q=q->next,i+=10)
  {
    gotoxy(i,9);printf("%f",atof((*q).x));
    gotoxy(i,11); printf("%f",atof((*q).y));
    gotoxy(i,13); printf("%f",(*q).Li);
    sum+=(atof((*q).y)*((*q).Li));
  }
 gotoxy(16,16);
 printf("y(%f)=%f",X0,sum);
 getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -