1. 程式人生 > >分數轉化為整int,int a=2/3,是0; int c=7/5;是1;不存在四捨五入。

分數轉化為整int,int a=2/3,是0; int c=7/5;是1;不存在四捨五入。

不存在四捨五入。

#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