C++ error C2784
#include"stdafx.h"#include<iostream>#include<cmath>usingnamespacestd;intmain(){floata...
#include "stdafx.h"
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float a,b,c,x1,x2,z;
cout<<"求解一元二次方程ax^2+bx+c=0的根。a,b,c的值在运算时输入,它们的值应满足b^2-4ac>=0";
cout<<"请输入a,b,c的值:";
cin>>a>>b>>c;
z=b*b-4*a*c;
if(z<0)
{
cout>>"can not calculate! wrong number~" ;
}
else
{
x1=((-b)+sqrt(b*b-4*a*c))/(2*a);
x2=((-b)-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
}
return 0;
}
1>.\求解1元2次.cpp(14) : error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::ostream'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\istream(1021) : see declaration of 'std::operator >>'
1>.\求解1元2次.cpp(14) : error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::ostream'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\istream(1021) : see declaration of 'std::operator >>'
可以帮我看一下是哪里错了吗 展开
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float a,b,c,x1,x2,z;
cout<<"求解一元二次方程ax^2+bx+c=0的根。a,b,c的值在运算时输入,它们的值应满足b^2-4ac>=0";
cout<<"请输入a,b,c的值:";
cin>>a>>b>>c;
z=b*b-4*a*c;
if(z<0)
{
cout>>"can not calculate! wrong number~" ;
}
else
{
x1=((-b)+sqrt(b*b-4*a*c))/(2*a);
x2=((-b)-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
}
return 0;
}
1>.\求解1元2次.cpp(14) : error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::ostream'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\istream(1021) : see declaration of 'std::operator >>'
1>.\求解1元2次.cpp(14) : error C2784: 'std::basic_istream<char,_Traits> &std::operator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::ostream'
1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\istream(1021) : see declaration of 'std::operator >>'
可以帮我看一下是哪里错了吗 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询