Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <math.h>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <sstream>
- using namespace std;
- string convertInt(int number)
- {
- stringstream ss;
- ss << number;
- return ss.str();
- }
- string A(int n)
- {
- string s="";
- for (int i = 1; i <= n; i++)
- {
- string prom = convertInt(i);
- if (i % 2 != 0)
- {
- s += "sin(";
- s += prom;
- if(i!=n)
- s += "-";
- }
- else
- {
- s += "sin(";
- s += prom;
- if (i != n)
- s += "+";
- }
- }
- for (int i = 1; i <= n; i++)
- s += ")";
- return s;
- }
- string S(int n)
- {
- string res="";
- for (int i = 1; i <= n-1; i++)
- res += "(";
- for (int i = n; i >=2; i--)
- {
- string prom = convertInt(i);
- res += A(n - i + 1);
- res += "+";
- res += prom;
- res += ")";
- }
- res += A(n);
- res += "+1";
- return res;
- }
- int main()
- {
- int n;
- cin >> n;
- cout << S(n);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment