- <div class="blockcode"><blockquote>#include <stdio.h>
- //1.定义加减乘除求余的函数
- void caculator(int a,int b,int *jia,int *jian,int *cheng,float *chu,int *yu){
- *jia = a + b;
- *jian = a - b;
- *cheng = a * b;
- *chu = a/(float)b;
- *yu =a%b;
- }
- int main(int argc, const char * argv[]) {
- //2.定义变量
- int x = 1, y = 1;
- int jia = 0;
- int jian = 0;
- int cheng = 0;
- float chu = 0.0f;
- int yu = 0;
- //3.提示用户输入两个数字
- printf("请输入两个数字,以空格隔开:");
- //4.保存用户输入的数字
- scanf("%d %d",&x,&y);
- //5.调用第一步的计算函数
- caculator(x, y, &jia, &jian, &cheng, &chu, &yu);
- //6.打印计算结果
- printf("jia = %d\n" ,jia);
- printf("jian = %d\n" ,jian);
- printf("cheng = %d\n" ,cheng);
- printf("chu = %0.2f\n",chu);
- printf("yu = %d\n" ,yu);
- /*int z=0,m=0;
- scanf("%d %d",&z,&m);
- printf("%d\n",z);
- printf("%d\n",m);*/
-
- return 0;
- }
复制代码
|
|