- #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;
- }
复制代码 |
|