第1个回答 推荐于2018-02-26
#include <stdio.h>
int main(void)
{
char ch;
scanf("%c",&ch);
if((ch>='0')||(ch<'0'+10))
{
printf("%d\n",ch-'0');
}
else
{
printf("%d\n",ch);
}
}本回答被提问者和网友采纳
第2个回答 2013-10-17
#include <stdio.h>
int main()
{
char() c;
while(1)
{
printf("input:");
c = getchar()();
getchar()();
if(c == 'N')//如果输入大写的N 就退出了 这个你自己随便设置
break;
if(c >= '0'&& c <= '9')
c = c - 48;
printf("%d\n",c);
}
system("pause");
return 0;
}
第3个回答 2013-10-17
#include <stdio.h>
int main()
{
char() c;
while(1)
{
printf("input:");
c = getchar()();
getchar()();
if(c == 'N')//如果输入大写的N 就退出了 这个你自己随便设置
break;
if(c >= '0'&& c <= '9')
c = c - 48;
printf("%d\n",c);
}
system("pause");
return 0;
}
第4个回答 2013-10-17
#include <stdio.h>
void main()
{
char c;
printf("input a char:");
scanf("%c",&c);
if((c>='0')&&(c<'0'+10))
printf("%d\n",c-'0');
else
{
printf("%d\n",c);
}
}