错误:流浪'\\ 240'计划中 [英] Error: stray '\240' in program

查看:158
本文介绍了错误:流浪'\\ 240'计划中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是要我来实现以下功能:

It is wanted of me to implement the following function:

void calc ( double* a, double* b, int r, int c, double (*f) (double) )

参数A,R,c和f被输入和b被输出。 一和B是用R行和c二维矩阵
列。 f为一个函数指针可以指向以下类型的任何功能:

Parameters a, r, c and f are input and b is output. "a" and "b" are 2d matrices with "r" rows and "c"  columns. "f" is a function pointer which can point to any function of the following type:

double function‐name ( double x ) { 
    … 
} 

功能在矩阵中的每个元素,即,AIJ,以BIJ矩阵B = F(AIJ)转换。

Function calc converts every element in matrix a, i.e., aij, to bij=f(aij) in matrix b.  

我实施功能如下,并把它放在一个程序来测试吧:

I implement the calc function as follows, and put it in a program to test it:

#include <stdlib.h>
#include <iostream>

using namespace std;

double f1( double x ){
    return x * 1.7;
}

void calc ( double* a, double* b, int r, int c, double (*f) (double) ) 
{
    double input;
    double output;

    for(int i=0;i<r*c;i++)
    {
        input=a[i];
        output=(*f)(input);
        b[i]=output;
    }
}

int main()
{
    //input array:
    int r=3;
    int c=4;
    double* a = new double[r*c];
    double* b = new double[r*c];

    //fill "a" with test data
    //...

    for (int i=0;i<r*c;i++)
    {
        a[i]=i;
    }


    //transform a to b
   calc ( a, b, r, c, f1 );

    //print to test if the results are OK
    //...

    for (int i=0;i<r*c;i++)
    {
        b[i]=i;
    }

    return 0;
}

问题是,我不能编译。这是输出的 DEVC ++ 的当我点击的编译和执行的按钮:

编译错误指的是无效字符

怎么了?

我AP preciate任何意见,使实施更有效的。

I appreciate any comment to make the implementation more efficient.

推荐答案

看样子你在你的源有非法字符。我想不出什么性格 \\ 240 应该是,但显然这是围绕10号线的起点

It appears you have illegal characters in your source. I cannot figure out what character \240 should be but apparently it is around the start of line 10

在code您发布,这个问题不存在: 住在Coliru

In the code you posted, the issue does not exist: Live On Coliru

这篇关于错误:流浪'\\ 240'计划中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆