main.c
来自「Jacobi GaussSeidel法求算式的根」· C语言 代码 · 共 34 行
C
34 行
#include <stdio.h>
#include<malloc.h>
#include<stdio.h>
#define NULL 0
struct node
{ int data;
int m;
struct node *next;
}sqlist;
void main()
{
struct node *p,*q,*l;
int i,k,temp,a[10]={4,7,6,3,4,6,8,1,9,3};
l=(struct node *)malloc(sizeof(struct node));
l->next=NULL;l->data=1;l->m=a[0];
p=l;
for(i=2;i<=10;i++)
{q=(struct node *)malloc(sizeof(struct node));
q->data=i;q->m=a[i-1];
p=q->next;p->next=NULL;}
l=p->next;
temp=a[0];
while(l->next!=l)
{i=0;
while(i!=temp)
{q=p;p=p->next;i++;}
temp=p->m;p->next=q->next;
l=p->next;}
printf("%d%d",l->data,l->m);
}
//#include <stdio.h>
//#include <stdlib.h>
//#include <conio.h>
//#include <math.h>
//#include"InputandOutput.h"
//#include"Jacobi.h"
//#include"GaussSeidel.h"
//
//void main()
//{ float A[MAX_n][MAX_n],x[MAX_n];
// int n;
// printf("\n请输入方程个数 n=");
// scanf("%d",&n);
// if(n>=MAX_n-1)exit(0);
// Matrix(A,n,n+1);
// if(!Jacobi(A,x,n)) {
// printf("\nJacobi计算结果:");
// Output(x,n);
// }
// if(!G_S(A,x,n)) {
// printf("\nG-S计算结果:");
// Output(x,n);
// }
// printf("\n\n按键退出\n");
// getch();
//}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?