随便输入一串字符将小写字母转化为大写字母。(不用到strupr函数)

用循环和数组的知识写,也不用到函数和指针

将读到的每一个小写字母的值加上32,就得到了对应的大写字母,然后输出就行了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-05-19
那就利用ASCII码 A-Z 与a-z的差是32
第2个回答  2008-05-19
#include <iostream.h>
#include <stdio.h >
void main()
{
char str[100],c;
int i=0;
while((c=getchar())!='\n')
{
str[i]=c>='a'&&c<='z'?c-32:c;
i++;
}
str[i]='\0';
cout<<str<<endl;
}
第3个回答  2008-05-19
#include <stdio.h>
#include <stdlib.h>
main()

{
char str[100];
char *tp = str;
scanf("%s",str);
while(*tp!='\0')
{
if(*tp>='a' && *tp<='z')
*tp += ('A'-'a');
tp++;
}
printf("after transfer : %s",str);
}
第4个回答  2021-05-11

相似回答