小编use*_*562的帖子

使用ostream作为参考(C++)

我有一个家庭作业,头文件提供给我们,并且是不可更改的.我无法弄清楚如何正确使用"显示"功能,所以这里是相关的代码.

头文件:

#ifndef SET_
#define SET_

typedef int EType;

using namespace std;

#include <iostream>

class Set
{
  private:

    struct Node
    {
      EType Item;     // User data item
      Node * Succ;    // Link to the node's successor
    };

    unsigned Num;     // Number of user data items in the set
    Node * Head;      // Link to the head of the chain

  public:

    // Various functions performed on the set

    // Display the contents of the set
    //
    void display( ostream& ) const; …
Run Code Online (Sandbox Code Playgroud)

c++ pass-by-reference ostream

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

为什么我的Python分散图不会起作用?

我使用pylab创建了一个非常简单的散点图.

pylab.scatter(engineSize, fuelMile)
pylab.show()
Run Code Online (Sandbox Code Playgroud)

该程序的其余部分不值得发布,因为它是那条线给我的问题.当我将"散射"更改为"情节"时,它会绘制数据图形,但每个点都是一条线的一部分,这使整个事情变得杂乱无章.我只是想要积分,而不是一条线,但我得到这个以下结尾的巨大错误信息:

  File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 1643, in amin
    return amin(axis, out)
TypeError: cannot perform reduce with flexible type
Run Code Online (Sandbox Code Playgroud)

python graph scatter matplotlib

5
推荐指数
2
解决办法
8332
查看次数

试图避免分段错误,但我的输出看起来很奇怪(C++)

我正在做的家庭作业项目使用静态和动态数组.但是,我还没有实现动态数组,这是一个奇怪的差异,试图获得我的静态数组的长度.

我使用了一系列cout语句来尝试找出导致分段错误的原因,因为这个过程看起来很简单.我发现在我的驱动程序中,它计算的是正确的范围和长度,但是一旦我将数组传递给用户定义的类函数,在同一个数组上执行的相同语句就会产生不同的结果.

我的驱动功能:

using namespace std;

#include <iostream>
#include "/user/cse232/Projects/project07.string.h"

int main()
{
  const char string1[] = {'a', 'b', 'c', 'd', 'e', 'f'};
  String test1();
  cout << "Size of array: " << sizeof(string1) << endl;
  cout << "Size of item in array: " << sizeof(char) << endl;
  cout << "Length of array: " << (sizeof(string1)/sizeof(char)) << endl;
  cout << "Range of array" << (sizeof(string1)/sizeof(char))-1 << endl << endl;

  String test2(string1);
}
Run Code Online (Sandbox Code Playgroud)

运行时,我从驱动程序获取此输出:

Size of array: 6
Size of item in …
Run Code Online (Sandbox Code Playgroud)

c++ arrays segmentation-fault

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