如何在不使用toupper和ASCII值的情况下在C ++中将小写字母更改为大写字母字符? [英] How do we change small letter to capital letter character in C++ without using toupper and ASCII value?
本文介绍了如何在不使用toupper和ASCII值的情况下在C ++中将小写字母更改为大写字母字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们不允许使用toupper或使用任何ASCII值。
我尝试过:
我无法得到任何解决方案。
We are not allowed to use toupper or do using any ASCII value.
What I have tried:
I am unable to get any solution.
推荐答案
你可以作弊:
You could cheat:
char c1 = 'a';
char c26 = 'z';
char upperC1 = (char)(c1 & 0xDF);
char upperC26 = (char)(c26 & 0xDF);
printf("%c:%c %c:%c\n", c1, upperC1, c26, upperC26);
查看ASCII表。大写字母A到Z的代码为0x41到0x5A,小写字母的代码为0x61到0x7A。
因为这看起来像家庭作业,我不会给你最终解决方案。但使用上述信息,您应该能够知道该怎么做。最后提示:
相应的大写和小写字母的代码有什么区别?
Have a look at the ASCII table. Upper case letters A to Z have codes of 0x41 to 0x5A and lower case letters have the codes 0x61 to 0x7A.
Because this looks like homework, I will not give you a final solution. But using the above information you should be able to know what to do. A final hint:
What is the difference in the code of corresponding upper case and lower case letters?
这篇关于如何在不使用toupper和ASCII值的情况下在C ++中将小写字母更改为大写字母字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文