[蓝桥杯]试题 基础练习 Sine之舞
程序员文章站
2022-05-11 22:50:45
...
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;
int main()
{
int n;
cin>>n;
/* 测试了可以不写
if(n < 1)
{
cout<<"";
return 0;
}
*/
vector<string>An(220,"");
char intStr[10];
string ch = "";
for(int i = n; i >= 1; i--)
{
string str = "";
itoa(i,intStr, 10);
ch = string(intStr);
str = "sin(" + ch + ")";
for(int j = i-1; j >= 1; j--)
{
itoa(j,intStr, 10);
ch = string(intStr);
str = "sin(" + ch + "+"+ str + ")";
}
//cout<<str<<endl;
An[i] = str;
}
string res = "";
itoa(n,intStr, 10);
ch = string(intStr);
res = An[1] + "+" + ch;
for(int i = 2; i <= n; i++)
{
itoa(n - i + 1,intStr, 10);
ch = string(intStr);
res = "("+res+")" +An[i] +"+" + ch;
}
cout<<res;
return 0;
}
上一篇: 压测工具ab的简单使用-总结
下一篇: 色环电阻辨认