下列程序会产生什么样的输出,为什么
假定输入为“Go west, young man!" , 以下程序会产生什么样的输出?为什么? 1.
#include <stdio.h>
int main(void)
{
char ch;
scanf ("%c",&ch);
while (ch != `g`)
{
printf ("%c",ch);
scanf ("%c",&ch);
}
return 0;
}
2.
#include <stdio.h>
int main(void)
{
char ch;
scanf ("%c",&ch);
while (ch != `g`)
{
printf ("%c",++ch);
scanf ("%c",&ch);
}
return 0;
}
3.
#include <stdio.h>
int main(void)
{
char ch;
do{
scanf ("%c",&ch);
printf ("%c",ch);
}while (ch !=`g`);
return 0;
}
4.
#include <stdio.h>
int main(void)
{
char ch;
scanf ("%c",&ch);
for(ch=`$`; ch != `g`; scanf ("%c",&ch))
putchar (ch);
return 0;
}