c语言四舍五入printf


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cmath>//应用log函数 
#define N 100005
#define ll long long 
using namespace std;
//printf和cout输出的不同 
int main()
{
	double t=0.62;
	double c=0.32;
	int a=t;
	int b=c;
	cout<< t<<c<<endl;
	printf("%.lf %.lf\n",t,c);//输出 1  0 
	printf("%lf %lf\n",t,c);//输出 0.62  0.32 
	printf("%d %d\n",a,b);//输出0  0,不会四舍五入 
	return 0;


发布了152 篇原创文章 · 获赞 4 · 访问量 3892

猜你喜欢

转载自blog.csdn.net/qq_43716912/article/details/100108636