正在加载图片...
The C Programming language Chapter 5 Control Flow 例判断输入字符种类 /*ch53.c*/ #include <stdio. h> maint char c printf("Enter a character c=getchar if(c<0x20) printf(" The character is a control characterIn") else if(c>=o'&&c<=9') printf("The character is a digit") else if(c>=A'&&c<=Z) printf( "The character is a capital letterin") else if(c>=a'&&c<=z) printf( "The character is a lower letterin") else printf("The character is other character n") :: Enter a character:& The character is other characterThe C Programming Language Chapter 5 Control Flow /*ch5_3.c*/ #include <stdio.h> main() { char c; printf("Enter a character:"); c=getchar(); if(c<0x20) printf("The character is a control character\n"); else if(c>='0'&&c<='9') printf("The character is a digit\n"); else if(c>='A'&&c<='Z') printf("The character is a capital letter\n"); else if(c>='a'&&c<='z') printf("The character is a lower letter\n"); else printf("The character is other character\n"); } 例 判断输入字符种类 运行:Enter a character:  The character is a control character :8  The character is a digit 运行: Enter a character: D The character is a capital letter 运行: Enter a character: h The character is a lower letter Enter a character:&  The character is other character
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有