第一种:只需要知道小写字母ASCII比大写字母多32
为了行数少一点就不写c2=c1-32
#include <stdio.h>
int main()
{
char c1;
c1=getchar();
printf("%c %d\n",c1-32,c1-32);
return 0;
}
第二种:不需要知道相差32
但是需要<ctype.h>
toupper转换为大写
tolower转换为小写
——————————————————
下面的别的题用得到
isalpha是否为字母
islower是否为小写字母
isupper是否为大写字母
isdigit是否为数字
#include <stdio.h>
#include <ctype.h>
int main()
{
char c1;
c1=getchar();
printf("%c %d\n",toupper(c1),toupper(c1));
return 0;
}
学习使我快乐,哈哈哈哈哈哈哈操哈哈哈