#include<bits/stdc++.h>
using namespace std;
int main()
{
double s,x;cin>>s>>x;
int t=0;
double ans=0;
double step=7;
while(ans<s-x){
ans+=step*(pow(0.98,t));
t++;
}
if(s+x-ans>=step*(pow(0.98,t))){
cout<<"y";
}else{
cout<<"n";
}
return 0;
}
本文展示了一个使用C++编写的程序实例,通过迭代计算特定数值序列,并基于比较结果输出字符'y'或'n'。该程序利用了标准输入输出流、数学幂运算及循环逻辑结构。

被折叠的 条评论
为什么被折叠?



