ACM问题 老PE 求改正 http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=1345
http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=1345我的代码:#include<iostream...
http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=1345
我的代码:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
using namespace std; // 1345
const double pi=acos(-1.0);
int main()
{
double w,h;
while(scanf("%lf%lf",&h,&w)!=EOF)
{
int i;
double going,rise;
double ming,maxg,minang,maxang;
printf("specs for n risers with height %.0lf mm and width at most %.0lf mm:\n",h,w);
for(i=1;i<=(int)(w/250.00)+1;i++)
{
going=w/i;
rise=h/i;
ming=550.00-2*rise;
if(ming-250.00<-1e-10)
ming=250.00;
maxg=700.00-2*rise;
if(maxg*i-w>1e-10)
maxg=w/i;
if((going-250.00>-1e-10)&&(190.00-rise>-1e-10)&&( 2.0*rise+ming-550.00>-1e-10 && 2.0*rise+maxg-700.00<1e-10)&&maxg-ming>-1e-10)
{
maxang=atan(h/(ming*i))/pi*180.00;
minang=atan(h/(maxg*i))/pi*180.00;
printf("n=%d r = %.2lf %.2lf <= g <= %.2lf %.2lf >= pitch >= %.2lf\n",i,rise,ming,maxg,maxang,minang);
}
}
printf("\n");
}
return 0;
} 展开
我的代码:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
using namespace std; // 1345
const double pi=acos(-1.0);
int main()
{
double w,h;
while(scanf("%lf%lf",&h,&w)!=EOF)
{
int i;
double going,rise;
double ming,maxg,minang,maxang;
printf("specs for n risers with height %.0lf mm and width at most %.0lf mm:\n",h,w);
for(i=1;i<=(int)(w/250.00)+1;i++)
{
going=w/i;
rise=h/i;
ming=550.00-2*rise;
if(ming-250.00<-1e-10)
ming=250.00;
maxg=700.00-2*rise;
if(maxg*i-w>1e-10)
maxg=w/i;
if((going-250.00>-1e-10)&&(190.00-rise>-1e-10)&&( 2.0*rise+ming-550.00>-1e-10 && 2.0*rise+maxg-700.00<1e-10)&&maxg-ming>-1e-10)
{
maxang=atan(h/(ming*i))/pi*180.00;
minang=atan(h/(maxg*i))/pi*180.00;
printf("n=%d r = %.2lf %.2lf <= g <= %.2lf %.2lf >= pitch >= %.2lf\n",i,rise,ming,maxg,maxang,minang);
}
}
printf("\n");
}
return 0;
} 展开
展开全部
这样输出:
printf("n=%d r = %6.2lf %6.2lf <= g <= %6.2lf %5.2lf >= pitch >= %5.2lf\n",i,rise,ming,maxg,maxang,minang);
2项数据间你看着是3个空格,但如果遇到一个2位数时,上下要对其,就变成4个空格了....
printf("n=%d r = %6.2lf %6.2lf <= g <= %6.2lf %5.2lf >= pitch >= %5.2lf\n",i,rise,ming,maxg,maxang,minang);
2项数据间你看着是3个空格,但如果遇到一个2位数时,上下要对其,就变成4个空格了....
追问
你给完整代码吧
参考资料: http://acm.swjtu.edu.cn/JudgeOnline/showmessage?message_id=1096
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询