提交时间:2023-10-04 23:15:51
运行 ID: 105001
#include<iostream> using namespace std; int main(){ int i=0,k=1; double dis[10],oil[10]; dis[0]=oil[0]=0; dis[1]=oil[1]=500; while(dis[k]<=1000){ k++; dis[k]=dis[k-1]+500/(2*k-1); oil[k]=k*500; } dis[k]=1000; oil[k]=(1000-dis[k-1])*(2*k-1)+oil[k-1]; for(k;k>0;k--){ cout<<"i="<<i++<<" dis="; printf("%.2lf",1000-dis[k]); cout<<" oil="; printf("%.2lf",oil[k]); cout<<endl; } return 0; }