【问题标题】:A stray '\342' compiler error in C++ for this code [duplicate]此代码的 C++ 中出现杂散的“\342”编译器错误 [重复]
【发布时间】:2015-10-23 19:37:23
【问题描述】:

我第一次遇到这种类型的“程序中的“stray '\342'”错误。

下面是我的代码

#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;
                                  ^

这个错误是什么意思?

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

【问题讨论】:

标签: c++ compiler-errors


【解决方案1】:

您的公式中的字符似乎不正确。

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;

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-20
    • 2011-01-21
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多