Sine之舞
思路
找规律的题目
#include<bits/stdc++.h>
using namespace std;
int n;
string A(int x) {
string temp;
if(x==1) {
temp="sin(1)";
return temp;
}
temp="sin(1";
for(int i=2; i<=x; i++) {
if(i%2==0) {
temp+="-sin(";
temp+=i-0+'0';
} else {
temp+="+sin(";
temp+=i-0+'0';
}
}
for(int i=1; i<=x; i++) {
temp+=")";
}
return temp;
}
string S(int x) {
string temp;
if(x==1) {
temp+=A(1);
temp+="+";
temp+=n-0+'0';
return temp;
}
temp += "(";
temp+=S(x-1);
temp+=")";
temp+=A(x);
temp+="+";
temp+=(n+1-x)-0+'0';
return temp;
}
int main() {
cin>>n;
cout<<S(n)<<endl;
}
版权声明:本文为qq_51960429原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。