除法 取模 后置 前置

 1 //除法 取模 后置 前置
 2 
 3 
 4 #include <stdio.h>
 5 int main()
 6 {
 7     //float num1 = 5.0;
 8     //float num2 = 2.0;
 9     int num1 = 5,num2 = 2;    //整形输出整形    float行输出小数点
10     //    num1++;
11     double result1,result2,result3,result4;     //4种结果
12     result1 = num1/num2;              //除法
13     result2 = num1%num2;              //取模
14     result3 = num1++;                 //后置
15     result4 = --num2;                 // 前置
16     printf("num1 / num2 =%f\n",result1);         //2.000000
17     printf("num1 %% num2 = %.lf\n",result2);       //1
18     printf("num1++ = %.2f\n",result3);             //5.00
19 //  printf("num1++ = %.2f\n",result3);             //6.00
20     printf("--num2 = %.3f\n",result4);             //1.000
21     return 0;
22 }

 

posted on 2021-07-28 12:26  Bytezero!  阅读(50)  评论(0编辑  收藏  举报