error C2601: 'main' : local function definitions are illegal 这是什么意思 ?怎么修改。。
#include<iostream>usingnamespacestd;doublefunction(doublea11,doublea12,doublea21,doub...
#include <iostream>
using namespace std;
double function (double a11,double a12,double a21,double a22,double b1,double b2){
double x,y;
if (b1==0 && b2==0)
cout<<"您输入的不是非齐次线性方程组,程序即将退出"<<endl;
else if (a11/a21==a12/a22 && a11/a21!=b1/b2)
cout<<"该方程无解"<<endl;
else if (a11/a21==a12/a22 && a11/a21==b1/b2)
cout<<"该方程组有无穷多解"<<endl;
else
{
y=(b2*a11-a21*b1)/(a22*a11-a21*a12);
x=(b1*a22-a12*b2)/(a11*a22-a21*a12);
cout <<"该方程组有唯一解,解为:"<< endl;
cout <<"x = " << fixed << x << endl;
cout <<"y = " << fixed << y << endl;
}
void main (void) {
double a11,a12,a21,a22,b1,b2;
cout<<"请输入系数矩阵中a11,a12,a21,a22的值:"<<endl;
cin>>a11>>a12>>a21>>a22;
cout<<"请输入短矩阵中b1,b2的值:"<<endl;
cin>>b1>>b2;
function (a11,a12,a21,a22,b1,b2);
system("pause");
}
} 展开
using namespace std;
double function (double a11,double a12,double a21,double a22,double b1,double b2){
double x,y;
if (b1==0 && b2==0)
cout<<"您输入的不是非齐次线性方程组,程序即将退出"<<endl;
else if (a11/a21==a12/a22 && a11/a21!=b1/b2)
cout<<"该方程无解"<<endl;
else if (a11/a21==a12/a22 && a11/a21==b1/b2)
cout<<"该方程组有无穷多解"<<endl;
else
{
y=(b2*a11-a21*b1)/(a22*a11-a21*a12);
x=(b1*a22-a12*b2)/(a11*a22-a21*a12);
cout <<"该方程组有唯一解,解为:"<< endl;
cout <<"x = " << fixed << x << endl;
cout <<"y = " << fixed << y << endl;
}
void main (void) {
double a11,a12,a21,a22,b1,b2;
cout<<"请输入系数矩阵中a11,a12,a21,a22的值:"<<endl;
cin>>a11>>a12>>a21>>a22;
cout<<"请输入短矩阵中b1,b2的值:"<<endl;
cin>>b1>>b2;
function (a11,a12,a21,a22,b1,b2);
system("pause");
}
} 展开
1个回答
展开全部
给你改过来了,运行通过
#include <iostream>
using namespace std;
void function(double a11,double a12,double a21,double a22,double b1,double b2)
{
double x,y;
if(b1==0 && b2==0)
cout<<"您输入的不是非齐次线性方程组,程序即将退出"<<endl;
else if (a11/a21==a12/a22 && a11/a21!=b1/b2)
cout<<"该方程无解"<<endl;
else if (a11/a21==a12/a22 && a11/a21==b1/b2)
cout<<"该方程组有无穷多解"<<endl;
else
{
y=(b2*a11-a21*b1)/(a22*a11-a21*a12);
x=(b1*a22-a12*b2)/(a11*a22-a21*a12);
cout <<"该方程组有唯一解,解为:"<< endl;
cout <<"x = " << fixed << x << endl;
cout <<"y = " << fixed << y << endl;
}
}
void main (void)
{
double a11,a12,a21,a22,b1,b2;
cout<<"请输入系数矩阵中a11,a12,a21,a22的值:"<<endl;
cin>>a11>>a12>>a21>>a22;
cout<<"请输入短矩阵中b1,b2的值:"<<endl;
cin>>b1>>b2;
function (a11,a12,a21,a22,b1,b2);
system("pause");
}
#include <iostream>
using namespace std;
void function(double a11,double a12,double a21,double a22,double b1,double b2)
{
double x,y;
if(b1==0 && b2==0)
cout<<"您输入的不是非齐次线性方程组,程序即将退出"<<endl;
else if (a11/a21==a12/a22 && a11/a21!=b1/b2)
cout<<"该方程无解"<<endl;
else if (a11/a21==a12/a22 && a11/a21==b1/b2)
cout<<"该方程组有无穷多解"<<endl;
else
{
y=(b2*a11-a21*b1)/(a22*a11-a21*a12);
x=(b1*a22-a12*b2)/(a11*a22-a21*a12);
cout <<"该方程组有唯一解,解为:"<< endl;
cout <<"x = " << fixed << x << endl;
cout <<"y = " << fixed << y << endl;
}
}
void main (void)
{
double a11,a12,a21,a22,b1,b2;
cout<<"请输入系数矩阵中a11,a12,a21,a22的值:"<<endl;
cin>>a11>>a12>>a21>>a22;
cout<<"请输入短矩阵中b1,b2的值:"<<endl;
cin>>b1>>b2;
function (a11,a12,a21,a22,b1,b2);
system("pause");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询