C语言求助
(1)while(ch=getchar()!='#')
(2)while((ch=getchar())!='#')
(1)和(2)有何区别?/???
谢谢!!!!!
#include "Stdio.h" #include "Conio.h"
main() ---------------------(1) { int v1=0,v2=0; char ch; while((ch=getchar())!='\n') switch(ch)
{ case 'k':v2++;break; case 'a': case 'h': default: v1++;break; } printf("%d,%d\ n",v1,v2); getch(); }
#include "Stdio.h" #include "Conio.h"
main() ------------------------(2) { int v1=0,v2=0; char ch; while(ch=getchar()!='\n') switch(ch)
{ case 'k':v2++;break; case 'a': case 'h': default: v1++;break; } printf("%d,%d\ n",v1,v2); getch(); } 在程序(1)中输入 kopk21
结果 4,2
在程序(2)中输入 kopk21
结果 6,0