假设你已经得到函数toUpper()
,定义为int toUpper(char)
,
如何实现函数toLower()
,即int toLower(char)
。
谢谢。
最佳答案
我想这是使用 toUpper
的现有实现的一种方式(注意 toLower
和 toUpper
被定义为吃 int
并且我已经这样做了;我假设您的 OP 中有错字):
int toLower(int c) {
for(int i = 0; i <= UCHAR_MAX; i++) {
if(c != i && toUpper(i) == c) {
return i;
}
}
return c;
}
编辑:谢谢,Chris Lutz .
关于c - 如果你已经获得了 toUpper(),如何实现 toLower(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4858639/