C++编程设计一个程序,输入两个整数,计算并输出两个整数的乘积和之差。

来源:百度知道 编辑:UC知道 时间:2024/05/25 00:54:07
设计一个程序,输入两个整数,计算并输出两个整数的乘积和之差。
书上就怎么写的,老师让做。3Q。
--------------------Configuration: 01 - Win32 Debug--------------------
Compiling...
3.cpp
d:\c++\01\3.cpp(3) : error C2065: 'scanf' : undeclared identifier
d:\c++\01\3.cpp(6) : error C2065: 'printf' : undeclared identifier
d:\c++\01\3.cpp(6) : error C2146: syntax error : missing ')' before identifier 'c'
d:\c++\01\3.cpp(6) : error C2059: syntax error : ')'
d:\c++\01\3.cpp(7) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.

01.exe - 1 error(s), 0 warning(s)
不能用啊,老兄,不过,还 是谢谢你,因为你花时间去替我想了,真的很不容易。

楼主不能只照抄楼上的代码,楼上的只是算法. ^_^
一下的你就可照抄 lol
下次有问题先想想,问问老师/同学...

/*
Name: Nub
Copyright: Mine >:D
Author: Sniper
Date: 08/09/07 22:26
Description: Good Stuff
*/

#include <iostream>
using namespace std;

int difference(int X,int Y);

int main()
{
int inputX,inputY,Ans;
cout << "Please input the first number:"; //X输入
cin >> inputX;
cout << "Please input the second number:"; //Y输入
cin >> inputY;
cout << "\nThe product of these two numbers is:" << (inputX * inputY) << "\n"; //积
cout << "The difference of these two numbers is:" << (inputX>=inputY?inputX-inputY:inputY-inputX) << "\n"; //差
system("pause");
return 0;
}

main()
{int a,b,c,d;
scanf