载入中。。。 'S bLog
 
载入中。。。
 
载入中。。。
载入中。。。
载入中。。。
载入中。。。
载入中。。。
 
填写您的邮件地址,订阅我们的精彩内容:


 
VC++学习笔记13-除法赋值与算子
[ 2010/7/25 20:54:00 | By: 梦翔儿 ]
 

//除法需要注意的事情
#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;
}

 
 
发表评论:
载入中。。。

 
 
 

梦翔儿网站 梦飞翔的地方 http://www.dreamflier.net
中华人民共和国信息产业部TCP/IP系统 备案序号:辽ICP备09000550号

Powered by Oblog.