为了账号安全,请及时绑定邮箱和手机立即绑定

输出格式问题

输出格式问题

C++
慕仰7464091 2018-02-05 10:46:23
c++输出数值过大时自动转化成1.84756e+06形式着么办,,double类型;cout<<dec<<s<<endl;题目:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3066代码如下:#include<iostream>using namespace std;    //关于这里,且听下回分解int main(){ int t,i,j; double n,m,s; cin>>t; for(i=0;i<t;i++) { s=1; cin>>n>>m; if(n>m-n) { for(j=1;j<=m;j++) { if(j>n) s*=j; cout<<s<<endl; } for(j=1;j<=n-m;j++) s/=j; } else { for(j=1;j<=m;j++) { if(j>m-n)s*=j; cout<<s<<endl; } for(j=1;j<n;j++) s/=j; } cout<<dec<<s<<endl; } return 0;}
查看完整描述

1 回答

?
慕仰7464091

TA贡献6条经验 获得超0个赞

用c我已经ac了,代码如下:

#include <stdio.h>

int main(int argc, char *argv[])

{

double t,s,z,n,m,b;

register int i,j;

scanf("%lf",&t);

for(i=0;i<t;i++)

{

scanf("%lf%lf",&n,&m);

if(n>m)

{

z=n;

n=m;

m=z;

}

s=1;

if(n>m-n)

{

for(j=1;j<=m;j++)

if(j>n)s*=j;

for(j=1;j<=m-n;j++)

s/=j;

}

else

{

for(j=1;j<=m;j++)

if(j>m-n)s*=j;

for(j=1;j<=n;j++)

s/=j;

}

printf("%.0f\n",s);

}

return 0;

}


查看完整回答
反对 回复 2018-02-05
  • 1 回答
  • 0 关注
  • 973 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信