2014-03-01 50 views
0

我正在嘗試製作一個程序來計算用戶輸入數字的y分量,以獲得7種不同的長寬比。這可能是頂部聲明中的一個簡單問題,但我對C++的經驗很少。我正在寫xcode。謝謝!xcode「期望非限定id」在cout上

我發現了以下錯誤消息:

19:13:無效的操作數的二進制表達式( '的std :: __ 1 :: basic_istream' 和 '')

32:6:預期不合格-id

// 
    // aspect1.cpp 
    // aspectRatioCalculator 
    // 


    #include <iostream> 

    using namespace std; 

    int main() 
    { 

    int a; 
    cout << "Enter a number to calculate its complements at multiple aspect ratios." << endl; 

    cin>> a >> endl; 

    int b = (a*9)/17; 
    int c = (a*9)/16; 
    int d = (a*5)/8; 
    int e = (a*4)/5; 
    int f = (a*3)/5; 
    int g = (a*3)/4; 
    int h = (a*2)/3; 

    cout << "17:9 | " << a << ":" << b << endl; 
    cout << "16:9 | " << a << ":" << c << endl; 
    cout << " 8:5 | " << a << ":" << d << endl; 
    cout << " 5:4 | " << a << ":" << e << endl; 
    cout << " 5:3 | " << a << ":" << f << endl; 
    cout << " 4:3 | " << a << ":" << g << endl; 
    cout << " 3:2 | " << a << ":" << h << endl; 

    } 

回答

0

std::endl是輸出操縱器。它不是用於輸入流(用於輸入)。將此更改爲:cin >> a >> endl;cin >> a; cout << endl;

相關問題