#include <iostream> #include <cmath> using namespace std; void main(){ double result ; int x,n=0,k = 2; cin >> x >> n; result = cos(pow(x, 1)); for (int i = 2;i<=n;++i) { if (i != k) result += cos(pow(x, i)); else { result -= cos(pow(x, i)); k += 3; } } cout << "result = " << result; system("pause"); }
#include <cmath>
using namespace std;
void main(){
double result ;
int x,n=0,k = 2;
cin >> x >> n;
result = cos(pow(x, 1));
for (int i = 2;i<=n;++i)
{
if (i != k)
result += cos(pow(x, i));
else
{
result -= cos(pow(x, i));
k += 3;
}
}
cout << "result = " << result;
system("pause");
}