Help with Program
I get the correct out but it doesn't want to line up, and it reaps each value five times.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
double pi = acos(-1.0);
double x[5] = {0, pi/6, pi/4, pi/3, pi/2};
double y[5] = {0, pi/6, pi/4, pi/3, pi/2};
double f[5][5];
cout << "x\t\tb\t\tc\n\n";
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
f[i][j] = 2.0 * sin((double)i) - cos((double)j);
cout << x[i] << "\t\t" << y[i] << "\t\t" << f[i][j] << "\n";
}
cout << "\n";
}
system("pause");
return 0;
}
|
line 23 is in the middle of a loop, so it repeats each time it loops.
Topic archived. No new replies allowed.