if else 和 if if 的区别if (ch == ' ')sp_ct++;else if (ch == '\n')nl_ct++;elseother++;和if (ch == ' ')sp_ct++;if (ch == '\n')nl_ct++;elseother++;这两个有什么区别

来源:学生作业帮助网 编辑:作业帮 时间:2024/03/29 05:31:18
if else 和 if if 的区别if (ch == ' ')sp_ct++;else if (ch == '\n')nl_ct++;elseother++;和if (ch == ' ')sp_ct++;if (ch == '\n')nl_ct++;elseother++;这两个有什么区别

if else 和 if if 的区别if (ch == ' ')sp_ct++;else if (ch == '\n')nl_ct++;elseother++;和if (ch == ' ')sp_ct++;if (ch == '\n')nl_ct++;elseother++;这两个有什么区别
if else 和 if if 的区别
if (ch == ' ')
sp_ct++;
else if (ch == '\n')
nl_ct++;
else
other++;

if (ch == ' ')
sp_ct++;
if (ch == '\n')
nl_ct++;
else
other++;
这两个有什么区别

if else 和 if if 的区别if (ch == ' ')sp_ct++;else if (ch == '\n')nl_ct++;elseother++;和if (ch == ' ')sp_ct++;if (ch == '\n')nl_ct++;elseother++;这两个有什么区别
if else是语法块,可以不需要else.
故你下面的这段程式是2个if else语法块,只是第一个if的else没有而已.
那么这两段就不能单看你说的这个区别了~
要分块理解,OK~?