//除法需要注意的事情
#i nclude <iostream>
#i nclude <iomanip>
#i nclude <string>
using namespace std;
void main()
{
float fvar = 11/4; //两个整型相除还是整数
printf("%f\n",fvar);
cout<<fixed<<showpoint; //如果用cout格式化输出,显示小数
cout<<setprecision(3)<<fvar<<endl; //精度
float fvar2 = 11/4.0; //4.0改为实数
cout<<fvar2<<endl;
}
========
//自增自减运算符,注意顺序
#i nclude <iostream>
#i nclude <string>
using namespace std;
void main()
{
int ivar=10;
int jvar=ivar++; //先赋值后相加
cout<<ivar<<endl;
cout<<jvar<<endl;
int ivar2=10;
int jvar2=++ivar2;//先相加后赋值
cout<<ivar2<<endl;
cout<<jvar2<<endl;
}
==========
#i nclude <iostream>
#i nclude <string>
using namespace std;
void main()
{
char carray[] = "hello"; //字符串还有\0结尾
cout<<sizeof(carray)<<endl;
}
=======
#i nclude <iostream>
#i nclude <string>
using namespace std;
void main()
{
int iret = 2;
iret = 3*5, iret*4; //等号优先于, 号
cout<<iret<<endl;
int iret2 = 2;
iret2 =(3*5, iret*4);
cout<<iret2<<endl;
}