如何编写一个c++代码,使函数在初始参数为大写时返回true,如果不是,则返回false
how to write a c++ code to make function that returns true if initial as an argument is capital, returns false if not
我想写一个程序,使函数在作为参数的initial为大写时返回true,如果不是,则返回false。作为一个论点,它对inital意味着什么#包括使用命名空间std;
bool IsUpper (char);
int main ( ) {
char ch;
cout << "Enter a letter: " ;
cin >> ch ;
if (IsUpper (ch))
cout << ch << " is a capital " << endl;
else
cout << ch << " is not a capital " << endl;
return 0;
}
bool IsUpper(char ch) {
{
if ((ch >= 'A' ) && (ch <= 'Z'))
return true;
else
return false;
}
return false;
}
根据您的代码,您可以替换:
bool IsAVowel (char ch) {
{
if ((ch >= 'A' ) && (ch <= 'Z'))
return true;
else
return false;
}
通过
bool isUpper(const char ch) {
return (ch >= 'A') && (ch <= 'Z');
}
相关文章:
- QueryWorkingSet总是返回false
- 当返回类型声明为 ListNode 时,我们是否可以返回 false<T>*
- 等于在 c++ 中返回 false
- strcmp 对于相等的字符序列返回 false
- C++ - 负数和正数之间的比较返回 false
- protobuf 的 ParseFromString 函数返回 false
- 递归函数始终返回 false
- 为什么 GetExitCodeThread() 在这里返回 FALSE?
- MFC 的 OnInit() 函数中的返回 true 和返回 false 有什么区别
- if 语句在条件为真时返回 false
- 为什么 std::isnan() 对于具有 NAN 值的双变量返回 false
- is_lock_free() 在升级到 MacPorts gcc 7.3 后返回 false
- 在 winapi 回调函数上返回 FALSE 时出现意外行为(循环被跳过?
- 如果数组中有重复的数字,如何返回'false'?
- std::is_array 当它应该返回 false 时返回 true
- 为什么pyarg_parsetuple总是返回false
- 删除为应该在哈希表中的记录返回 false 的函数
- Vulkan 和 glfwVulkanSupported() 总是返回 false
- tf2_ros::Buffer::canTransform() 为现有转换返回 False
- 出于某种原因,布尔值返回 false