竹園論壇

標題: C++語法問題(I) [打印本頁]

作者: JasonTsai@FB    時間: 2014-10-2 23:33
標題: C++語法問題(I)
本帖最後由 JasonTsai@FB 於 2014-10-27 22:59 編輯

[C++] 純文本查看 復制代碼
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int main()
{
    float input, a, b, c;
    scanf("%f%f",&a,&input);
    if (input > a)
    b = input;
    else
    {
        b = a;
        input = b;
    }
    scanf("%f",&input);
    if (input > b)
    c = input;
    else if (input > a)
    {
        c = b;
        b = input;
    }
    else
    {
        c = b;
        b = a;
        a = input;
    }
    if (c > a + b)
    {
        if (c * c > a * a + b * b)
        printf("acute\n");
        else if (c * c == a * a + b * b)
        printf("right\n");
        else
        printf("obtuse\n");
        cout >> sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c)) / 4;
    }
    else
    printf("illegal\nunavailable");
    system("pause");
    return 0;
}

以上是我寫的三角形判斷的程式(詳細見http://moodle.tnfsh.tn.edu.tw/mod/assignment/view.php?id=2992),在編譯時顯示38行語法有誤(no match for 'operator>>' in 'std::cout>> #`rdiv_expr' not supported by dump_expr#<expression error>'),但我一直找不出哪裡出錯,請各位幫忙一下,謝謝。



作者: Sylveon    時間: 2014-10-3 07:40
因為是
[C++] 純文本查看 復制代碼
cout << sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c)) / 4;

作者: JasonTsai@FB    時間: 2014-10-4 22:41
啊......「<<」方向錯了......
那這樣沒問題了




歡迎光臨 竹園論壇 (http://forum.tfcis.org/) Powered by Discuz! X3.2