program_2_6.cpp

来自「本程序为visual c++课件讲义」· C++ 代码 · 共 27 行

CPP
27
字号
// Program 2.6: Compute the y-coordinate of a
// point on a line given the line and an x-coordinate
// Authors: Bryan Zeng
// Date: 7/24/2002

#include <iostream>
using namespace std;
int main() {
	// Input line s parameters
	cout << "Slope of line (integer)? ";
	int m;  // Line slope
	cin >> m;
	cout << "Intecept of y-axis (integer)? ";
	int b;  // y-intercept
	cin >> b;
	// Input x-coordinate of interest
	cout << "x-coordinate of interest (integer)? ";
	int x;  // x-coordinate of interest
	cin >> x;
	// compute and display y-coordinate
	int y;
	y = m * x + b;
	cout << "y = " << y << " when m = " << m << ";";
	cout << " b = " << b << "; x = " << x << endl;
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?