狗狗身体发抖一直喘气:谁能说明一下c语言的题3

来源:百度文库 编辑:高考问答 时间:2024/05/02 06:29:04
(22)要求通过while循环不断读入字符,当读入字母N时结束循环。若变量已正确定义,
以下正确的程序段是
A)while((ch=getchar())!='N') printf("%c",ch);
B)while(ch=getchar()!='N') printf("%c",ch);
C)while(ch=getchar()=='N') printf("%c"),ch);
D)while((ch=getchar())=='N') printf("%c",ch);
谁能说明一下个行的意思
说的越详细越好

A)while((ch=getchar())!='N') printf("%c",ch); //正确,因为要求是等于N就继续...
B)while(ch=getchar()!='N') printf("%c",ch); //不能使用连等式
C)while(ch=getchar()=='N') printf("%c"),ch); //同上
D)while((ch=getchar())=='N') printf("%c",ch); //跟题目意思刚好相反

与问题2类似。。。。

恩,与问题2类似
A)while((ch=getchar())!='N') printf("%c",ch); //正确,因为要求是等于N就继续...
B)while(ch=getchar()!='N') printf("%c",ch); //不能使用连等式
C)while(ch=getchar()=='N') printf("%c"),ch); //同上
D)while((ch=getchar())=='N') printf("%c",ch); //跟题目意思刚好相反

说得很好呀