编写程序输入一个小写字母,如何将其转换为大写字母输出

如题所述

以java为例,可以使用String类的toUpperCase()方法。

如图所示:

拓展资料:

Java toUpperCase() 方法:

toUpperCase() 方法将字符串小写字符转换为大写。

语法

public String toUpperCase()或public String toUpperCase(Locale locale)

Java toLowerCase() 方法:

toLowerCase() 方法将字符串转换为小写。

语法

public String toLowerCase()或public String toLowerCase(Locale locale)



温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-07-07

小写字母的ASCII码比对应的大写字母的多32,所以只需要将字符-32并输出即可,具体如如下:

第2个回答  2013-10-18
大小写字母的ascii码相差32,举例a的ascii码是97,A的ascii码是65#include"stdio.h"main(){ char i,j; scanf("%c",&i); j=i-32; printf("%c",j);}
第3个回答  2013-10-18
#include <stdio.h>
#include <conio.h>
void main()
{
char c;
while (1)
{
c = _getch();
if (c == 0x0d)
break;
if (c >= 'a' && c <= 'z')
c-= 32;
putchar(c);
}
return;
}你想用什么语言实现? 这个是C语言 可以实现
第4个回答  2013-10-18
#include <stdio.h>

main()

{
char ch_low;
char ch_upper;

printf("Please input a lower character:");
scanf("%c",& ch_low);
ch_upper = ch_low-32;

printf("\nThis character's Upper is %c.",ch_upper);

}