%%%%%%%%

 1  1 //强制类型转换
 2  2 // https://blog.csdn.net/chaipp0607/article/details/54834954 
 3 
 4     double x;
 5     int y1,y2;
 6     scanf("%lf",&x);
 7     y1=int(x);
 8     y2=int(round(x));
 9     printf("%d\n",y1);
10     printf("%d\n",y2);
11     /*
12     5.9
13     5
14     6
15     */

 

 1 scanf("%lf",&x);
 2 int m=x;
 3 cout<<m<<endl; 
 4 5.7
 5 5
 6 5.2
 7 5
 8 想几舍x入最简单的办法是在原数上加个1-0.x就可以了,
 9 如:想四舍五入就——      5.4   int(5.4+0.5)=5
10                         5.5   int(5.5+0.5)=6
11 又如:想二舍三入就——    5.2   int(5.2+0.7)=5  
12                         5.3   int(5.3+0.7)=6                         

 

 

1   3+0.5 会自动转换成double 
2   int a;
3   ll  b;
4   a+b //自动换为ll 

 

转载于:https://www.cnblogs.com/tingtin/p/9341523.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值