发布网友 发布时间:2022-04-22 05:24
共2个回答
热心网友 时间:2023-07-17 03:16
void main (void){
int ret;
int a = 3;
int b = 7;
ret = add(a,b);
printf("ret =%d\n",ret);
}
改成这样就好了。
其他的类似。
ret = add(a,b);
printf("ret =%d\n",ret);
ret = sub(a,b);
printf("ret =%d\n",ret);
ret = mul(a,b);
printf("ret =%d\n",ret);
ret = dive(a,b);
printf("ret =%d\n",ret);
完整的程序请看附件
热心网友 时间:2023-07-17 03:16
/* HELLO.C -- Hello, world */
#include "stdio.h"
#include "conio.h"
main()
{
int chu(int a,int b);
int cheng(int a,int b);
int jian(int a,int b);
int jia(int a,int b);
int chh(char c, int a, int b);
int a,b,result;
char ch,c;
printf("please input a,b: ");
scanf("%d,%d",&a,&b);
printf("please input char:");
fflush(stdin);
ch=getchar();
result=chh(ch,a, b);
printf("result=%d",result);
getch();
}
int chh(char c, int a, int b)
{
int ch_ret = 0;
switch(c)
{
case '+': ch_ret = jia(a,b);break;
case '-': ch_ret = jian(a,b);break;
case '*': ch_ret = cheng(a,b);break;
case '/': ch_ret = chu(a,b);break;
}
return ch_ret;
}
int jia(int a,int b)
{
int jia=0;
jia=a+b;
return jia;
}
int jian(int a,int b)
{
int jian=0;
jian=a-b;
return jian;
}
int cheng(int a,int b)
{
int cheng=0;
cheng=a*b;
return cheng;
}
int chu(int a,int b)
{
int chu=0;
chu=a/b;
return chu;
}追问
然而却没有调试成功啊 ,我想知道用我写的哪种方法怎么写出来这个加减运算