您的位置:首页 > 其它

csu 1049 第一次串讲——输入输出练习题

2012-03-13 11:48 141 查看
C++好处理一些,C语言使用 log10(double x) 计算 x 整数部分的位数(结果要 +1):

# include <stdio.h>
# include <math.h>

int main()
{
int n, j, tmp;
double x, tot;

freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);

while (~scanf("%d%d", &n, &j))
{
tot = 0;
while (n--)
{
scanf("%lf~", &x);
tot += x;
}
j -= (int)((log10(tot)) + 5);
while(j-- > 0) putchar(' ');
printf("%.3lf\n", tot);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: