谁来改一下这个C++……

[复制链接]
查看11 | 回复4 | 2009-5-29 12:30:25 | 显示全部楼层 |阅读模式
#include#include //加这个头文件。pow需要用到int round(float x,int n){float z; long i; i=pow(10,n); z=(long)(x*i+0.5)/(float)i; return i;}main(){ float x,y;int n;printf("input x n\n");scanf("%f%d",&x,&n);y=(float)round(x,n);//y是float型。round函数返回的是int 需要强制转换一下printf("x=%f,...
回复

使用道具 举报

千问 | 2009-5-29 12:30:25 | 显示全部楼层
z=(long)(x*i+0.5)/(float)i; return i;这函数真奇怪, 算了一圈的z然后返回了个别的东西。。...
回复

使用道具 举报

千问 | 2009-5-29 12:30:25 | 显示全部楼层
pow函数要一个头文件#inlclude...
回复

使用道具 举报

千问 | 2009-5-29 12:30:25 | 显示全部楼层
pow函数好像还得定义吧。。。...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行