码迷,mamicode.com
首页 > 其他好文 > 详细

double long float类型读入读出 double取模 fmod

时间:2017-06-03 09:59:18      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:data-   name   div   post   cpp   cstring   rar   long   ace   

The library of fmod is #include <cmath>

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<cstring>
#include<cmath>
using namespace std;

int main(){
  double x;
  long y;
  long long z;

  scanf("%lf",&x);
  double doubleMod = fmod(x,(double)3);
  printf("The result of x mod 3 is %.2lf\n",doubleMod);

  scanf("%ld",&y);
  printf("The result of y is %ld\n", y);

  scanf("%lld", &z);
  printf("The result of z is %lld\n", z);

	return 0;
}

  cout << (-5) % 3 << endl;   // 结果是-2!。。!!。!!

!!!!!

!!。!

!!

。!。!!


  cout << fmod((double)(-5), (double)(-3))<<endl; //结果是-2!。!

!。!

!!!

!!

!!!!!


double long float类型读入读出 double取模 fmod

标签:data-   name   div   post   cpp   cstring   rar   long   ace   

原文地址:http://www.cnblogs.com/jzssuanfa/p/6936204.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!