基础训练 Sine之舞
作者:互联网
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<string> A(n+1,"");
for(int i=1; i<=n; i++){
string str="";
str.append(1, '0'+i);
for(int j=i; j>0; j--){
str="sin("+str+")";
if(j>1){
char c=char('0'+(j-1));
if(j%2==1)
str="+"+str;
else
str="-"+str;
str.insert(str.begin(), 1, c);
}
}
A[i]=str;
}
string ans="";
for(int i=n; i>0; i--){
char c='0'+i;
if(i==n){
ans=A[n+1-i]+"+";
ans.append(1, c);
}else{
ans="("+ans+")"+A[n+1-i]+"+";
ans.append(1, c);
}
}
cout<<ans<<endl;
return 0;
}
标签:include,int,char,基础训练,str,ans,Sine,之舞,append 来源: https://www.cnblogs.com/A-Little-Nut/p/10350979.html