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

2024-10-30 13:37:04
推荐回答(2个)
回答1:

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

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

#include
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;
}

回答2:

main()
{int a,b,c,d;
scanf("%d%d",&a,&b);
c=a*b;
d=a-b;
printf("%d,%d\n"c,d);
}