小编use*_*796的帖子

未定义对代码块中功能的引用

我在头文件和源文件中有此代码。这是代码的小片段。这是来自.cpp文件。

int sample(Cdf* cdf)  
{
    //double RandomUniform();
    double r = RandomUniform(); //code that is causing the error
    for (int j = 0; j < cdf->n; j++)
    if (r < cdf->vals[j])
    return cdf->ids[j];
    // return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是从.c文件:

double RandomUniform(void)
{
    double uni;

    /* Make sure the initialisation routine has been called */
    if (!test) 
    RandomInitialise(1802,9373);

    uni = u[i97-1] - u[j97-1];
    if (uni <= 0.0)
    uni++;
    u[i97-1] = uni;
    i97--;

    // ...
}
Run Code Online (Sandbox Code Playgroud)

这是从我的头文件

void   RandomInitialise(int,int);
double …
Run Code Online (Sandbox Code Playgroud)

c c++ codeblocks

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

数字格式化读取文本文件时的异常

我正在阅读包含多列数据集的文本文件.我正在使用Memreader,我已将每列分配为索引,以便将输出打印到目标文件.然而,对于我的生活,我无法弄清楚为什么我一直得到这个'数字格式例外'.我已经完成了通常的obj.nextLine()跳过标题,我已经为数据集中的所有值分配了'int'数据类型,并确保数据集只有int值,以便于测试,但仍然得到错误.这是我的代码:

   public class MemReader implements Serializable{

private static final long serialVersionUID = 7526472295622776147L;

public OpenIntObjectHashMap movieToCust;
public OpenIntObjectHashMap custToMovie;
public OpenIntIntHashMap sumByCust;
public OpenIntIntHashMap sumByMovie;


/**
 * Default constructor. Initializes hashtables. 
 */
public MemReader() {
    movieToCust = new OpenIntObjectHashMap();
    custToMovie = new OpenIntObjectHashMap();    
    sumByCust = new OpenIntIntHashMap();
    sumByMovie = new OpenIntIntHashMap();
}


/**
 * Reads a text file in the form 
 *
 * mid,uid,rating
 *
 * and stores this data in the custToMovie and 
 * movieToCust hashtables. 
 *
 * @param …
Run Code Online (Sandbox Code Playgroud)

java

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

标签 统计

c ×1

c++ ×1

codeblocks ×1

java ×1