C++程序又不对了

来源:百度知道 编辑:UC知道 时间:2024/06/08 11:28:35
求4个数中最大的;
#include<iostream>
using namespace std;
int main ()
{
int a,b,c,d,t,t1,t2;
cout<<"input a,b,c,d"<<endl;
cin>>a>>b>>c>>d;
cout<<"a=<<a<<endl;
cout<<"b="<<b<<endl;
cout<<"c="<<c<<endl;
cout<<"d="<<d<<endl;
t=(a>b)?a:b;
t1=(t>c)?t:c;
t2=()t1>d)?t1:d;
cout<<"max="<<t2<<endl;
return 0;
}
--------------------Configuration: 和 - Win32 Debug--------------------
Compiling...
和.cpp
E:\王浩\和.cpp(8) : error C2001: newline in constant
E:\王浩\和.cpp(9) : error C2146: syntax error : missing ';' before identifier 'cout'
E:\王浩\和.cpp(14) : error C2059: syntax error : ')'
E:\王浩\和.cpp(14) : error C2059: syntax error : &

改为:
int main ()
{
int a,b,c,d,t,t1,t2;
cout<<"input a,b,c,d"<<endl;
cin>>a>>b>>c>>d;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
cout<<"c="<<c<<endl;
cout<<"d="<<d<<endl;
t=(a>b)?a:b;
t1=(t>c)?t:c;
t2=(t1>d)?t1:d;
cout<<"max="<<t2<<endl;
return 0;
}

小哥你请看好,你的编译器告诉你了
新行有一个常量,说明你有一个定义错了
然后接连的3个错误是粗心错误:少了;和),好好找找吧

cout<<"a=<<a<<endl;
改为:
cout<<"a="<<a<<endl;