小编Bru*_*cky的帖子

警告:扩展初始化程序列表仅适用于-std = c ++ 0x或-std = gnu ++ 0x

我尝试声明一个矩阵,当我编译时,我得到这个:

extended initializer lists only available with -std=c++0x or -std=gnu++0x
Run Code Online (Sandbox Code Playgroud)

在尝试其他解决方案时,我得到了这个:

ISO C++ forbids variable length array 'A' (line 16)
Run Code Online (Sandbox Code Playgroud)

这是我上次尝试的代码:

#include<iostream>
#include<cmath>
#include<fstream>
#include<cstdlib>
using namespace std;

int main()
{

int m, l;

ifstream MatrixA ("A.txt");
MatrixA >> m;
MatrixA >> l;

int A [m][l];

for (int lineA = 0; lineA <= m; lineA++)
{
    for (int colA = 0; colA <= l; colA++)
    {
        A [lineA][colA];
    }
}

cout << "Matrix A: " << A[m][l] << endl;

return …
Run Code Online (Sandbox Code Playgroud)

c++ matrix

2
推荐指数
1
解决办法
1534
查看次数

在C++中遇到'while'循环时遇到问题

我开始用C++构建一个非常简单的计算器版本.我们的想法是只用两个数字执行基本操作,然后循环回来,这样用户就可以进行新的计算.

该程序如下所示:

#include<iostream>
#include<string>
#include"mathOperations.h"
using namespace std;

int main()
{
  int x, y;
  string operation;
  string repeat = "y";

  while (repeat == "y" or "Y")
  {
    cout << "Welcome! This is a raw version of a calculator - only use two numbers." << endl;
    cin >> x >> operation >> y;

    if (operation == "+")
    {
      cout << "Result: " << add(x, y) << endl;
    }
    else if (operation == "-")
    {
      cout << "Result: " << subtract(x, y) …
Run Code Online (Sandbox Code Playgroud)

c++ while-loop

1
推荐指数
1
解决办法
73
查看次数

标签 统计

c++ ×2

matrix ×1

while-loop ×1