您的位置 电脑知识爱好者 >> 编程知识 >> if条件不进行判断,只执行a=m的语句

if条件不进行判断,只执行a=m的语句

电脑知识爱好者互联网本站整理2007-9-5 0:32:57
知识重点:#include iostream.h void main() { char a; cout你的性别endl; cina; if(a=m) { int b; coutxendl; cinb; coutxbxendl; } else if(a=f) { int c; coutxendl; cinc; coutxc..

#include <iostream.h> void main() { char a; cout<<"你的性别"<<endl; cin>>a; if(a='m') { int b; cout<<"x"<<endl; cin>>b; cout<<"x"<<b<<"x"<<endl; } else if(a='f') { int c; cout<<"x"<<endl; cin>>c; cout<<"x"<<c<<"x"<<endl; } else { cout<<"x"<<endl; cout<<"x"<<endl; cout<<"0"<<endl; } cout<<"感谢您参与本权威测试"<<endl; cout<<"祝您愉快!"<<endl; } 你的条件判断语句全都写错了。a=应写成a==。前者是赋值符号,默认返回值为真,后者才是判断符号。

参与评论
相关内容
关于我们 | 隐私政策 | 站点地图 | 站长博客|京ICP备07025396号
添加到百度搜藏 添加到百度搜藏 电脑知识爱好者Copyright ?2006-2008版权所有 我要啦免费统计