C++程序。输入一个字符,如果为字母,则输出其ASCII码

2024-11-26 05:20:57
推荐回答(1个)
回答1:

#include
using
namespace
std;
int
main()
{
char
ch;
while(cout<<"Enter
one
Character(ctrl+z
to
end):"<>ch)
{
if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
cout<<"ASCII:"<(ch)<}
return
0;
}
//标准的C++程序
//static_cast(ch)是C++中的强制类型转换
//以下针对修改程序
#include
using
namespace
std;
int
main()
{
char
ch;
cout<<"Enter
one
Character:"<cin>>ch;
if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
cout<<"ASCII:"<(ch)<return
0;
}