所以第一个函数将输入乘以pi并使其成为cos,而第二个函数将相同的输入乘以pi并使其成为sin。然后在int main中,我创建了一个for循环,以便存储来自用户的值,然后我将调用我的两个函数来完成剩下的工作,但它给了我错误,我不知道为什么
这是代码:
#include <iostream>
#include<iomanip>
#include <cmath>
using namespace std;
double xpicos(double x)
{//const double pi = 3.14159265;
double xpicos = cos(x*pi);
return xpicos;
}
double xpisin(double x)
{const double pi = 3.14159265;
double xpisin = sin(x*pi);
return xpisin;
}
int mian ()
{
const double pi = 3.14159265;
double x=0;
double y = 0;
const int capacity = 200;
double corners[capacity];
cout << "enter" ;
for (int i = 0; i < 200; i++)
{cin >> corners[i];
double x = xpicos(corners[i]);
double y =xpisin(corners[i]);
}
cout << x << "," << y ;
return 0;
}
答案 0 :(得分:1)
好的我包括这个答案来帮助你(尽管我怀疑这个问题会被关闭)。你的代码有一些明显的错误(你拼错了......)。这应该是:
#include <iostream>
#include<iomanip>
#include <cmath>
using namespace std;
double xpicos(double x)
{
const double pi = 3.14159265;
return cos(x*pi);
}
double xpisin(double x)
{
const double pi = 3.14159265;
return sin(x*pi);
}
int main ()
{
double x = 0.0;
double y = 0.0;
const int capacity = 200;
double corners[capacity];
cout << "enter: " << endl;
for (int i = 0; i < 200; i++){
cin >> corners[i];
x = xpicos(corners[i]);
y = xpisin(corners[i]);
}
cout << x << "," << y << endl; //you can move this inside the for loop
//if that is what you want
return 0;
}
答案 1 :(得分:1)
您的代码中存在很多错误和错误。您不需要iomanip
,main
拼写mian
,pi
不在正确的范围内,您重新声明x
和y
以及cout
for
已经失去了'\n'
循环,可能需要在每一行之后#include <iostream>
#include <cmath>
using namespace std;
const double pi = 3.14159265;
double xpicos(double x)
{
double xpicos = cos(x*pi);
return xpicos;
}
double xpisin(double x)
{
double xpisin = sin(x*pi);
return xpisin;
}
int main ()
{
const int capacity = 200;
double corners[capacity];
cout << "Enter: " << endl;
for (int i = 0; i < 200; i++)
{
cin >> corners[i];
double x = xpicos(corners[i]);
double y = xpisin(corners[i]);
cout << x << ", " << y << endl;
}
return 0;
}
。所以更像是:
config.before do
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
答案 2 :(得分:0)