输入两个整数,进行加减乘除四则运算的c语言程序怎么写啊,拜托了~
3个回答
展开全部
#include<stdio.h>
void function(int a, int b)
{
printf("%d add %d = %d\n",a, b, a+b); //加法运算
printf("%d sub %d = %d\n",a, b, a-b); //加法运算
printf("%d mul %d = %d\n",a, b, a*b); //乘法运算
printf("%d div %d = %d\n",a, b, a/b); //除法运算
}
int main()
{
int a,b;
printf("please input a and b");
scanf("%d%d",&a,&b);
function(a,b);
return 0;
}
void function(int a, int b)
{
printf("%d add %d = %d\n",a, b, a+b); //加法运算
printf("%d sub %d = %d\n",a, b, a-b); //加法运算
printf("%d mul %d = %d\n",a, b, a*b); //乘法运算
printf("%d div %d = %d\n",a, b, a/b); //除法运算
}
int main()
{
int a,b;
printf("please input a and b");
scanf("%d%d",&a,&b);
function(a,b);
return 0;
}
展开全部
#include<conio.h>
#include<windows.h>
#include<iostream>
using namespace std;
main(void)
{
float a,b;
char ch;
while(1)
{
cin>>a>>ch>>b;
//scanf("%d%c%d",&a,&ch,&b);
if(ch=='+')
//printf("= %f \n",a+b);
cout<<"="<<a+b<<endl;
if(ch=='-')
//printf("= %f \n",a-b);
cout<<"="<<a-b<<endl;
if(ch=='*')
//printf("= %f \n",a*b);
cout<<"="<<a*b<<endl;
if(ch=='/')
//printf("= %f \n",a/b);
cout<<'='<<a/b<<endl;
system("cls");
}
return 0;
}
#include<windows.h>
#include<iostream>
using namespace std;
main(void)
{
float a,b;
char ch;
while(1)
{
cin>>a>>ch>>b;
//scanf("%d%c%d",&a,&ch,&b);
if(ch=='+')
//printf("= %f \n",a+b);
cout<<"="<<a+b<<endl;
if(ch=='-')
//printf("= %f \n",a-b);
cout<<"="<<a-b<<endl;
if(ch=='*')
//printf("= %f \n",a*b);
cout<<"="<<a*b<<endl;
if(ch=='/')
//printf("= %f \n",a/b);
cout<<'='<<a/b<<endl;
system("cls");
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<iostream>
using namespace std;
main()
{
float a,b;
char ch;
while(1)
{
cin>>a>>ch>>b;
//scanf("%d%c%d",&a,&ch,&b);
if(ch=='+')
//printf("= %f \n",a+b);
cout<<"="<<a+b<<endl;
if(ch=='-')
//printf("= %f \n",a-b);
cout<<"="<<a-b<<endl;
if(ch=='*')
//printf("= %f \n",a*b);
cout<<"="<<a*b<<endl;
if(ch=='/')
//printf("= %f \n",a/b);
cout<<'='<<a/b<<endl;
system("cls");
}
return 0;
}
using namespace std;
main()
{
float a,b;
char ch;
while(1)
{
cin>>a>>ch>>b;
//scanf("%d%c%d",&a,&ch,&b);
if(ch=='+')
//printf("= %f \n",a+b);
cout<<"="<<a+b<<endl;
if(ch=='-')
//printf("= %f \n",a-b);
cout<<"="<<a-b<<endl;
if(ch=='*')
//printf("= %f \n",a*b);
cout<<"="<<a*b<<endl;
if(ch=='/')
//printf("= %f \n",a/b);
cout<<'='<<a/b<<endl;
system("cls");
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询