黑马程序员技术交流社区
标题:
[函数加指针]超简版计算器(仅供浏览,请勿深究)
[打印本页]
作者:
1wang2huan
时间:
2015-9-3 08:09
标题:
[函数加指针]超简版计算器(仅供浏览,请勿深究)
#include <stdio.h>
void calculator(int num1,int num2,int *sum,int *jian,int *cheng ,float *chu){
*sum = num1+num2;
*jian = num1 -num2;
*cheng = num1*num2;
*chu = (float)num1/num2;
}
int main(int argc, const char * argv[]) {
int num1,num2;
int sum,jian,cheng;
float chu;
printf("请输入两个整数:\n");
scanf("%d,%d",&num1,&num2);
calculator(num1, num2, &sum, &jian,&cheng, &chu);
printf("%d+%d = %d\n",num1,num2,sum);
printf("%d-%d = %d\n",num1,num2,jian);
printf("%d*%d = %d\n",num1,num2,cheng);
printf("%d+%d = %.2f\n",num1,num2,chu);
return 0;
}
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2