# include "stdio.h" main() { char a,b,x1,x2; printf("please input two word\n"); scanf("%c,%c",&a,&b); a=('a'<=x1<='z')?x1-32:x1; b=('a'<=x2<='z')?x2-32:x2; if('A'<=a<='Z'&&'A'<=b<='Z') printf("two is zhimu \n"); else if('A'<=a<='Z'&&'0'<=b<='9') printf("one is zhimu,one is shuzhi \n"); else if('0'<=a<='9'&&'A'<=b<='Z') printf("one is shuzhi,one is zhimu \n"); else if('0'<=a<='9'&&'0'<=b<='9') printf("two is shuzhi \n"); else printf("error \n"); getch(); }
我输入什么都只打印two is zhimu
----------------解决方案--------------------------------------------------------
# include "stdio.h" main() { char a,b,x1,x2; printf("please input two word\n"); scanf("%c,%c",&a,&b); a=('a'<=x1<='z')?x1-32:x1; b=('a'<=x2<='z')?x2-32:x2; if('A'<=a<='Z'&&'A'<=b<='Z') printf("two is zhimu \n"); else if('A'<=a<='Z'&&'0'<=b<='9') printf("one is zhimu,one is shuzhi \n"); else if('0'<=a<='9'&&'A'<=b<='Z') printf("one is shuzhi,one is zhimu \n"); else if('0'<=a<='9'&&'0'<=b<='9') printf("two is shuzhi \n"); else printf("error \n"); getch(); }
我输入什么都只打印two is zhimu
----------------解决方案--------------------------------------------------------
a=('a'<=x1<='z')?x1-32:x1;
'a'<=x1<='z'这个是什么意思你知道吗?怎么计算的?基础没学好就想飞?
----------------解决方案--------------------------------------------------------
改后是这样的
#include <stdio.h> main() { char a,b; scanf("%c %c",&a,&b); a=('a'<=a&&a<='z')?(a-32):a; b=('a'<=b&&b<='z')?(b-32):b; if(('A'<=a&&a<='Z')&&('A'<=b&&b<='Z')) printf("two zimu"); else if(('A'<=a&&a<='Z')&&('0'<=b&&b<='9')) printf("a is zimu,b is shuzi"); else if(('A'<=b&&b<='Z')&&('0'<=a&&a<='9')) printf("b is zimu,a is shuzi"); else if(('0'<=a&&a<='9')&&('0'<=b&&b<='9')) printf("two shuzi"); else printf("qita"); getch(); }
----------------解决方案--------------------------------------------------------
a=('a'<=x1<='z')?x1-32:x1;
'a'<=x1<='z'这个是什么意思你知道吗?怎么计算的?基础没学好就想飞?
knocker说的也太重了吧
我看了一天书就写了类似给他改正的程序
用不到多少基础啊
----------------解决方案--------------------------------------------------------
knocker说的也太重了吧
我看了一天书就写了类似给他改正的程序
用不到多少基础啊
我的意思是这个程序在学C的第一天就可以写出来
很正常的 加油
----------------解决方案--------------------------------------------------------
是的啊 我只看了一天的书 菜是当然的啊
a=('a'<=x1<='z')?x1-32:x1;
这么写是对了啊 我调试过了
意思就是x1在是小写的字母就把它改成大写
----------------解决方案--------------------------------------------------------
兄弟,可以试下这个
# include "stdio.h"
main()
{
char a,b,x1,x2;
printf("please input two word\n");
scanf("%c,%c",&x1,&x2);
a=('a'<=x1&&x1<='z')?x1-32:x1;
b=('a'<=x2&&x2<='z')?x2-32:x2;
if ('A'<=a&&a<='Z'&&'A'<=b&&b<='Z')
printf("two is zhimu \n");
else if ('A'<=a&&a<='Z'&&'0'<=b&&b<='9')
printf("one is zhimu,one is shuzhi \n");
else if ('0'<=a&&a<='9'&&'A'<=b&&b<='Z')
printf("one is shuzhi,one is zhimu \n");
else if ('0'<=a&&a<='9'&&'0'<=b&&b<='9')
printf("two is shuzhi \n");
else printf("error \n");
getch();
}
----------------解决方案--------------------------------------------------------
是的啊 我只看了一天的书 菜是当然的啊
a=('a'<=x1<='z')?x1-32:x1;
这么写是对了啊 我调试过了
意思就是x1在是小写的字母就把它改成大写
不是这样的,如果你输入的是小写字母'a'<=x1成立使得整个式子变成a=(1<='z')?x1-32:x1;
当然输出结果是正确的.
----------------解决方案--------------------------------------------------------
2004-9-22 14:35:00
----------------解决方案--------------------------------------------------------