分数转化为整int,int a=2/3,是0; int c=7/5;是1;不存在四舍五入。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38998213/article/details/83717358

不存在四舍五入。

#include <iostream>
 
using namespace std;
 
int main ()
{

    int a=2/3;
    int b=3/4;
    int  c=7/5;
  
    cout << a << endl;
    cout << b << endl;
    cout << c << endl;
 
   return 0;
}

结果:

0
0
1

猜你喜欢

转载自blog.csdn.net/qq_38998213/article/details/83717358
int