1 #include<bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 int N; 5 char t; 6 cin>>N; 7 string s=""; 8 string A="",T="",H=""; 9 for(int i=0;i<N-1;i++){ 10 //s初始设为"n-1个‘(‘" 11 s+=‘(‘; 12 } 13 14 for(int i=1;i<=N;i++){ 15 //A[i]="A" + "sin(" + "i" + "i个)" 16 T+=‘)‘;//T是‘)‘的叠加体 17 A+="sin("; 18 t=‘0‘+i; 19 A+=t;//A是A[i]的叠加体 20 H=A+T; //H表示A[i] 21 22 //s="s" + "H" + "+" + "n-i+1" + "1个)" 23 s+=H; 24 s+=‘+‘; 25 t=‘0‘+(N-i+1); 26 s+=t; 27 if(i!=N) s+=‘)‘; 28 29 //为下一个A[i]做准备 加上正负号 30 if(i%2==1) A+=‘-‘; 31 else A+=‘+‘; 32 } 33 34 cout<<s<<endl; 35 }
原文:https://www.cnblogs.com/Aiahtwo/p/12741581.html