C语⾔⼏个重要的ascii值
⽂章⽬录
ascii共有多少个字符新知
ascii 码记忆,利⽤字符达到ascii码效果
0 - 9 ascii 是 48-57
‘A’ - ‘Z’ ascii 是 65-90
‘a’ - ‘Z’ ascii 是 97-122
switch case 的常量表达式的可取类型
switch的case 常量表达式的 值 必须要是整数,因为只有整数才可以列举 ,故可以是 整型、char 型、枚举类型。
case 9:
case ‘A’:
‘\n’占⽤⼀个字节。
练习根据ascii码
练习:
从键盘输⼊⼀个字符
如果是⼩写字母则把它转成对应的⼤写字母
如果是⼤写字母则把它转成对应的⼩写字母
如果是数字,就不改变
然后输出
其它的不处理,也不输出
int main()
{
char test ;
scanf("%c",&test);
if(test >=65&& test <=90)//'A' - 'Z'
printf("%c\n", test +32);//输出 'a' - 'z'
else if(test >=97&& test <=122)// 'a' - 'z'
printf("%c\n", test -32);//输出 'A' - 'Z'
else if(test >=48&& test <=57)// 0 - 9
printf("%c\n", test);//输出0 - 9
else//其他
;
}
/
/⼀般写⼤于’0’,⼩于’9’就不⽤记ascii码了
int main()
{
char test ;
scanf("%c",&test);
if(test >='A'&& test <='Z')//'A' - 'Z'
printf("%c\n", test +32);//输出 'a' - 'z'
else if(test >='a'&& test <='z')// 'a' - 'z'
printf("%c\n", test -32);//输出 'A' - 'Z'
else if(test >='0'&& test <='9')// 0 - 9
printf("%c\n", test);//输出0 - 9
else//其他
printf("unknow\n");
}
请你写⼀个程序判断7是否是质数int main()
{
int i;
int a;
scanf("%d",&a);
for(i =2; i < a; i++)
{
if(a % i ==0)
{
printf("不是质数\n");
break;
}
}
if(i == a)
printf("是质数\n");
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。