我正在尝试制作一个程序来计算7种不同宽高比的用户输入数字的y分量。这可能是顶部声明中的一个简单问题,但我对c ++的经验很少。我在写xcode。谢谢!
我收到以下错误消息:
19:13:二进制表达式的操作数无效('std :: __ 1 :: basic_istream'和'')
32:6:预期不合格的身份
//
// 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 :(得分:0)
std::endl
是输出操纵器。它不适用于输入流(用于输入)。将此更改为cin >> a >> endl;
至cin >> a; cout << endl;
。