c++ - 此代码在 C++ 中出现杂散的 '\342' 编译器错误

标签 c++ compiler-errors

<分区>

第一次遇到这种“stray '\342' in program”的错误。

下面是我的代码

#include <bits/stdc++.h>

using namespace std;

#define sc(n) scanf("%d",&n)
#define tc1 cin>>t;while(t--)
#define forf(i, a, b) for(i =(a); i <(b); ++i)

int main()
{
    long long int t, x1, x2, x3, y1, y2, y3, points, temp;

    float area;
    tc1
    {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        temp = x1*y2 + x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;
        area = 0.5f * abs(temp);
        points = area + 1 - (3/2);
        cout << points << "\n";
    }
    return 0;
}

下面是我的编译错误:

solution.cc:18:9: error: stray '\342' in program
     temp=x1*y2 +x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;
     ^
solution.cc:18:9: error: stray '\210' in program
solution.cc:18:9: error: stray '\222' in program
solution.cc:18:9: error: stray '\342' in program
solution.cc:18:9: error: stray '\210' in program
solution.cc:18:9: error: stray '\222' in program
solution.cc:18:9: error: stray '\342' in program
solution.cc:18:9: error: stray '\210' in program
solution.cc:18:9: error: stray '\222' in program
solution.cc: In function 'int main()':
solution.cc:18:38: error: expected ';' before 'x1'
     temp=x1*y2 +x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;
                                  ^

这个错误是什么意思?

我无法通过之前回答的问题理解此错误的确切含义。

最佳答案

看起来您的公式中有不正确的字符。

temp=x1*y2 +x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;

不一样

temp=x1*y2 +x2*y3 + x3*y1 -x1*y3 - x3*y2 - x2*y1;

如您所见,(-) 是不同的。

关于c++ - 此代码在 C++ 中出现杂散的 '\342' 编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33310174/

相关文章:

c++ - 函数重载如何与 double 和 float 一起工作

c++ - 如何使用 Win32/MFC API 提取 .iso 文件?

C++调用类的模板函数作为模板参数

compiler-errors - Verilog分配编译器错误

C 通过引用函数传递复杂结构

c++ - 在 vector 上插入 C++

c++ - 捕获 QVector 对象的 "index out of range"异常

c++ - std set_union 是否总是从第一个开始获取公共(public)元素

python - 如何忽略 OSError : [Errno 2] in Python, os linux、usbtmc

C++11 未定义的函数引用