注册 登录
编程论坛 C++教室

新人求助........

罗斯曼丽 发布于 2012-10-24 22:05, 621 次点击
只有本站会员才能查看附件,请 登录
我的作业.....求指教  错在哪儿???
12 回复
#2
青春无限2012-10-24 23:26
看看
#3
lz10919149992012-10-24 23:27
完整代码发上来看看。
#4
rjsp2012-10-25 08:08
应当是 cout << ( XXX ? XXX : XXX );
注意优先级
#5
pangding2012-10-27 10:48
优等级的问题确实是比较容易被疏忽。
#6
天剑山2012-10-27 14:37
优先级问题,加一个()就可以了
#7
罗斯曼丽2012-10-27 21:23
回复 6楼 天剑山
在哪儿加  ()
#8
stuniversity2012-10-27 23:12
回复 7楼 罗斯曼丽
4楼的括号不是很清楚了吗?
#9
zyflrj2012-10-27 23:57
学了!
#10
罗斯曼丽2012-10-28 09:05
崩溃了.............什么优先等级我们老师就没有提过...............
我改成这样了..............
cout<< ("A:"<<A==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("B:"<<B==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("C:"<<C==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("D:"<<D==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("E:"<<E==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("F:"<<F==0?"不是":"是")<<"罪犯" <<endl;
但是还有错误啊 ...............
E:\作业\p51罪犯\1.cpp(16) : error C2001: newline in constant
E:\作业\p51罪犯\1.cpp(18) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(19) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(20) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(21) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(22) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(23) : error C2296: '<<' : illegal, left operand has type 'char [3]'
#11
罗斯曼丽2012-10-28 09:06
回复 6楼 天剑山
崩溃了.............什么优先等级我们老师就没有提过...............
我改成这样了..............
cout<< ("A:"<<A==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("B:"<<B==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("C:"<<C==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("D:"<<D==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("E:"<<E==0?"不是":"是")<<"罪犯" <<endl;
cout<< ("F:"<<F==0?"不是":"是")<<"罪犯" <<endl;
但是还有错误啊 ...............
E:\作业\p51罪犯\1.cpp(16) : error C2001: newline in constant
E:\作业\p51罪犯\1.cpp(18) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(19) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(20) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(21) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(22) : error C2296: '<<' : illegal, left operand has type 'char [3]'
E:\作业\p51罪犯\1.cpp(23) : error C2296: '<<' : illegal, left operand has type 'char [3]'
#12
超级菜鸟手2012-10-28 09:49
你都() 放错了
试看看 (A==0? "不是" : "是")
#13
zxd5432012-10-28 10:05
要是都等着老师交 估计你不明白的多了去了
语言类的一定要自学 有些你问老师他都不一定会
1