如何在c++中解决这个输出
how to solve this output in C++
#include <iostream>
#include <ctype.h>
using namespace std;
typedef char Txt80[80];
int main()
{
char *PText;
Txt80 Txt = "Ur2GReAt";
int N = 6;
PText = Txt;
while (N >=3)
{
Txt[N] = (isupper(Txt[N] ? tolower(Txt[N]):toupper(Txt[N])));
cout << PText <<endl;
N--;
PText++;
}
}
Output is :
Ur2GRe
r2GR
2G
我很困惑,因为根据循环内使用的三元操作符,如果第6个值是小写字母,它应该将其转换为大写字母。这里'e'是小写的,但输出仍然是小写的,它只是在循环的第一次运行中打印前6个字符。然后在第二次运行中,N递减,从2开始打印。请解释
看起来像这样:
Txt[N] = (isupper(Txt[N] ? tolower(Txt[N]):toupper(Txt[N])));
将Txt[N]
设置为零,有效地截断了那里的字符串。backkets的配置看起来很可疑——我想知道您的意思是否类似:
Txt[N] = (isupper(Txt[N]) ? tolower(Txt[N]) : toupper(Txt[N]));
相关文章:
- 无法在问题解决方案中执行输出逻辑
- 从排序数组中删除重复项,具有不同代码方式的相同解决方案具有不同的输出
- 使用模数时如何解决C++输出负数?
- 调试解决方案,对某些操作的每个输出进行 #if
- 贝金纳C++练习解决方案的意外输出
- 我的输出文件未显示解决方案
- 所需的输出为66.6,但我会得到giber虫(如下所示),如何解决此问题
- 创建子过程并从中获取实时输出.(欢迎跨平面解决方案)
- Arduino Uno 串行监视器不会打印整个输出;如何解决?
- C++实现代码中的字符串不应存在于输出二进制文件中.如何解决
- 找出迷宫求解器的最佳解决方案,并具有动画输出
- 我写了一个函数来删除循环链接列表中的第 1 个节点,但输出显示无限次"55 44 33 22 11 99",那么我该如何解决呢?
- 我的 vscode 的控制台输出看起来很奇怪,如何解决它
- 谁能帮助我解决以下 c++ 代码中的问题?该程序不提供任何输出
- VS2012 如何将 C# 的 AnyCPU 配置的输出目录设置为各自解决方案配置的 x86 和 x64 文件夹?
- 简单程序没有输出和崩溃.我的解决方案有什么问题
- 简单解决方案的输出不正确
- 在任何情况下都会出现意外输出.我的解决方案出了什么问题
- 正在将控制台输出重定向到同一解决方案中的MFC屏幕输出
- 输出不符合我的预期结果,如何解决