关于C语言的一个题目...麻烦大家了...
2.输入一个字符(1)若为字母,输出“alpha”,再进行大小写转换:若为小写,输出相应的大写字母,若为大写,输出相应的小写字母(2)若为数字,输出“digit”(3)若...
2.输入一个字符
(1)若为字母,输出“alpha”,再进行大小写转换:若为小写,输出相应的大写字母,若为大写,输出相应的小写字母
(2)若为数字,输出“digit”
(3)若为其它字符,输出 “not alpha & digit”
输出alpha和大小写转换都不会...其实最好把全部写出来...我是个贪婪的人..+v+
#include <stdio.h>
main()
{
char c;
printf("Enter a char:");
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z') printf("This is an alpha.\n");
else if(c>='A'&&c<='Z') printf("This is a capital letter.\n");
else if(c>='a'&&c<='z') printf("This is a lower letter.\n");
else if(c>='0'&&c<='9') printf("This is a digit.\n");
else printf("This is not an alpha or a digit.\n");
}
自己写了这个觉得过不了关...- - 展开
(1)若为字母,输出“alpha”,再进行大小写转换:若为小写,输出相应的大写字母,若为大写,输出相应的小写字母
(2)若为数字,输出“digit”
(3)若为其它字符,输出 “not alpha & digit”
输出alpha和大小写转换都不会...其实最好把全部写出来...我是个贪婪的人..+v+
#include <stdio.h>
main()
{
char c;
printf("Enter a char:");
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z') printf("This is an alpha.\n");
else if(c>='A'&&c<='Z') printf("This is a capital letter.\n");
else if(c>='a'&&c<='z') printf("This is a lower letter.\n");
else if(c>='0'&&c<='9') printf("This is a digit.\n");
else printf("This is not an alpha or a digit.\n");
}
自己写了这个觉得过不了关...- - 展开
7个回答
展开全部
#include <stdio.h>
main()
{
char c;
printf("Enter a char:");
c = getchar();
if (c >= 'a' && c <= 'z')
printf("This is an alpha.------------%c\n", c + 'A' - 'a');
else if (c >= 'A' && c <= 'Z')
printf("This is an alpha.------------%c\n", c -' A' + 'a');
else if (c >= '0' && c <= '9')
printf("This is an digit.\n");
else printf("This is not an alpha or a digit.\n");}
main()
{
char c;
printf("Enter a char:");
c = getchar();
if (c >= 'a' && c <= 'z')
printf("This is an alpha.------------%c\n", c + 'A' - 'a');
else if (c >= 'A' && c <= 'Z')
printf("This is an alpha.------------%c\n", c -' A' + 'a');
else if (c >= '0' && c <= '9')
printf("This is an digit.\n");
else printf("This is not an alpha or a digit.\n");}
展开全部
//你的程序不符合题目要求,改成下面。
#include <stdio.h>
void main()
{
char c;
printf("Enter a char:");
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
{printf("alpha.\n");
if(c>='a'&&c<='z')
printf("%c\n",c-32);
else
printf("%c\n",c+32);
}
else if(c>='0'&&c<='9') printf("digit.\n");
else printf("not alpha & digit.\n");
}
#include <stdio.h>
void main()
{
char c;
printf("Enter a char:");
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
{printf("alpha.\n");
if(c>='a'&&c<='z')
printf("%c\n",c-32);
else
printf("%c\n",c+32);
}
else if(c>='0'&&c<='9') printf("digit.\n");
else printf("not alpha & digit.\n");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
int main(void)
{
char c;
printf("Enter a char:");
c=getchar();
if (c >= 'a' && c <= 'z')
{
c -= 32;
printf("alpha: %c\n", c);
}
else if (c >= 'A' && c <= 'Z')
{
c += 32;
printf("alpha: %c\n", c);
}
else if (c >= '0' && c <= '9')
{
printf("digit\n");
}
else printf("not alpha & digit");
return 0;
}
int main(void)
{
char c;
printf("Enter a char:");
c=getchar();
if (c >= 'a' && c <= 'z')
{
c -= 32;
printf("alpha: %c\n", c);
}
else if (c >= 'A' && c <= 'Z')
{
c += 32;
printf("alpha: %c\n", c);
}
else if (c >= '0' && c <= '9')
{
printf("digit\n");
}
else printf("not alpha & digit");
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
void main()
{
char c;
printf("Enter a char:");
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
{
printf("alpha.\n");
if(c>='a'&&c<='z')
printf("%c\n",c-32);
else
printf("%c\n",c+32);
}
else if(c>='0'&&c<='9') printf("digit.\n");
else printf("not alpha & digit.\n");
}
} 用这个规范
void main()
{
char c;
printf("Enter a char:");
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
{
printf("alpha.\n");
if(c>='a'&&c<='z')
printf("%c\n",c-32);
else
printf("%c\n",c+32);
}
else if(c>='0'&&c<='9') printf("digit.\n");
else printf("not alpha & digit.\n");
}
} 用这个规范
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
void main()
{
char c;
printf("Enter a char:");
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
{ printf("alpha.\n");
if(c>='A'&&c<='Z') printf("%c\n", c+32);
else printf("%c\n",c-32);
}
else if(c>='0'&&c<='9') printf(" digit.\n");
else printf("This is not an alpha or a digit.\n");
}
void main()
{
char c;
printf("Enter a char:");
c=getchar();
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
{ printf("alpha.\n");
if(c>='A'&&c<='Z') printf("%c\n", c+32);
else printf("%c\n",c-32);
}
else if(c>='0'&&c<='9') printf(" digit.\n");
else printf("This is not an alpha or a digit.\n");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
void main(){
char ch;
int i='A'-'a'; //求出大小写字母ascII码差值
scanf("%c",&ch);
if (ch>='a' && ch<='z')
printf("alpha\n%c\n",ch+i);
else if (ch>='A' && ch<='Z')
printf("alpha\n%c\n",ch-i);
else if (ch>='0' && ch<='9')
printf("digit\n");
else
printf("not alpha & digit\n");
}
void main(){
char ch;
int i='A'-'a'; //求出大小写字母ascII码差值
scanf("%c",&ch);
if (ch>='a' && ch<='z')
printf("alpha\n%c\n",ch+i);
else if (ch>='A' && ch<='Z')
printf("alpha\n%c\n",ch-i);
else if (ch>='0' && ch<='9')
printf("digit\n");
else
printf("not alpha & digit\n");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |