点滴积累,路虽远,行必至!
程序1,将2个结构域值相加,乘以2再加50
#include<iostream> using namespace std; int result(int, int); const int k = 2; struct point{ int x, y; }; int main() { int z(0), b(50); point a; cout << "请输入2个整数(以空格分割):"; cin >> a.x >> a.y; z = (a.x + a.y) * k; z = result(z, b); cout << "输出结果如下:" << endl; cout << "(" << a.x << "+" << a.y << ")" << "*" << k << "+" << b << "=" << z << endl; return 0; } int result(int a, int b) { int c(0); c = a + b; return c; }
end!