立即注册 登录
萝卜钛客 返回首页

TYH的个人空间 https://robotaics.com/?150 [收藏] [复制] [RSS]

日志

c++20250730

|已有 102 次阅读|2025-7-30 17:38

1.等差排列:
#include<iostream>
using namespace std;
int main() {
int n,n1,n2,n3;
cin>>n>>n1>>n2;
int d=n2-n1;
bool e=1;
for(int i=0;i<n-2;i++){
cin>>n3;
if(n2+d!=n3){
e=0;
break;
}
n2=n3;
}
if(e){
cout<<'T';
}else{
cout<<'F';
}
return 0;
}
2.多项式的值:
#include<iostream>
using namespace std;
int main() {
int n;
float x,c=0,z=1;
cin>>x>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
z*=x;
}
c+=z;
z=1;
}
printf("%.2f",c+1);
return 0;
}

全部作者的其他最新日志

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

返回顶部