作业帮 > 综合 > 作业

C语言输入函数是怎么计算的 就是用sanf "%a%b"%&%&,进行+-*/运算是怎么运算的?

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/23 00:35:42
C语言输入函数是怎么计算的 就是用sanf "%a%b"%&%&,进行+-*/运算是怎么运算的?
就是用sanf "%a%b"%&%&,进行+-*/运算是怎么运算的?
C程序是怎么运算的呢?
C语言输入函数是怎么计算的 就是用sanf
同志,sanf函数?是你自己写的函数,还是系统带的?据我所知,系统好像没有sanf函数!
如果是笔误,为scanf函数,那么
#include
void main()
{
int a,b;
printf("输入两个整数\n");
scanf("%d%d",&a,&b);
printf("%d\n",a+b);
}
如果是自己写,那么
#include
void sanf(int a,int b)
{
char choose;
getchar();
printf("请输入运输的种类:* or / or + or -\n");
scanf("%c",&choose);
switch(choose)
{
case '*':printf("%d * %d = %d\n",a,b,a*b);break;
case '/':printf("%d / %d = %d\n",a,b,a/b);break;
case '+':printf("%d + %d = %d\n",a,b,a+b);break;
case '-':printf("%d - %d = %d\n",a,b,a-b);break;
default:printf("ERROR!\n");
}
}
void main()
{
int a,b;
printf("输入两个数 :");
scanf("%d%d",&a,&b);
sanf(a,b);
}