为什么是Y 而不是y?

lanrain1012 2008-05-21 12:09:20
程序如下:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

long factorial(long);


int main(int argc, char *argv[])
{
char ch;
long n;
printf("Factorial counting using recursive---");
do
{
printf("\nEnter a number to count(0<=n<=12) to count n!:");
scanf("%d",&n);
if(n<0||n>12)
printf("input out of range!\n");
else
printf("%ld!=%ld\n",n,factorial(n));

printf("Continue?");
ch=toupper(getche());
} while(ch=='Y');//这里为什么用大写Y,而用小写y就不能继续运行?
system("PAUSE");
return 0;
}

long factorial(long n)
{
if(n==1||n==0)
return(1);
else
return (n*factorial(n-1));
}
...全文
149 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
brookmill 2008-05-21
  • 打赏
  • 举报
回复
ch被前一行的toupper转成大写了
ch=toupper(getch());
fengwenqi 2008-05-21
  • 打赏
  • 举报
回复
同意楼上,进行了大小写转换!
XSign 2008-05-21
  • 打赏
  • 举报
回复
2楼正解。
tbocd 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch()); 

[/Quote]

re
pengzhixi 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch());
[/Quote]
Soulic 2008-05-21
  • 打赏
  • 举报
回复
之前进行了大小写的转换
grellen 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch());

[/Quote]
leelittlelong 2008-05-21
  • 打赏
  • 举报
回复
ch=toupper(getche());
} while(ch=='Y');//这里为什么用大写Y,而用小写y就不能继续运行?


改成ch==tolower(getche())


就可以用y了。
socrates 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 sailinghz 的回复:]
引用 1 楼 brookmill 的回复:
ch被前一行的toupper转成大写了
ch=toupper(getch());

[/Quote]
sailinghz 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch());
[/Quote]
frank_323 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch());
[/Quote]
huaxiangsl 2008-05-21
  • 打赏
  • 举报
回复
同意楼上
ninesuns02 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch());
[/Quote]
zgmary 2008-05-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 brookmill 的回复:]
ch被前一行的toupper转成大写了
ch=toupper(getch());
[/Quote]

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧