int型不能用指数形式输出吗

C语言 码拜 7年前 (2017-05-01) 1298次浏览
]#include<stdio.h>
int main(){
int t,s;
int n;
t=1;
s=0;
for(n=1;n<=20;n++){
t = t*n;
s = s+t;
}
printf(“%22.15e\n”,s); //出错?
return 0;
}
解决方案

10

当然了,指数输出的是实数(float或double)

10

printf(“%22.15e\n”,(double)s);

5

printf("%22.15e\n", s*1.0);

转换一下即可。


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明int型不能用指数形式输出吗
喜欢 (0)
[1034331897@qq.com]
分享 (0)