C++编程帮助!它不会工作?

标签 c++ visual-c++

第一列包含数字 1 到 5 后续列包含乘以数字的结果 第一列数字 0 到 9

好的,我已经走到这一步了,但它不起作用,我不知道为什么!如果您能指出正确的方向,那将非常有帮助:)

#include <iostream>
using namespace std;

int main()
{
    for ( int i=0 ; i < 5; i++)
    { 
        cout << " ";
        // end for

        for ( int j = 0; j>=i; j ++) 
            cout << endl;
    }  // end for

    return 0;
}   //end of main function

最佳答案

The first column contains the numbers 1 through 5 Subsequent columns contain the result of multiplying the number in the First column by the numbers 0 through 9

嗯..

  • 在您的代码段中,外循环从 0 到 4。但问题是从 1 到 5。
  • 内循环应该从 0 到 9 运行,这意味着它独立于外循环的 i 值。所以,内循环的条件 j>=i 是错误的。

关于C++编程帮助!它不会工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5462317/

相关文章:

c++ - fatal error LNK2019 C++,Unreal Engine Build

c++ - 带有引用的运算符转换的值不正确

c++ - MFC COleControl::DoPropExchange 在哪里存储持久属性?

c++ - 组合或替换多个相似的重载

c++ - addr2line 中的 "discriminator"是什么?

c++ - 为什么Visual Studio生成的C++ "Hello World"项目看起来有点奇怪?

C++ 标准 : Unexpected const_iterator in multiset

c++ - 将距离公式计算为给定的双整数

c++ - 负数的按位运算会导致ub吗?

c++ - Visual Studio编译错误查找文件