Need Help With C++
#1
Im wrote this program for my class but dont have C++ to run it can someone run it and see how it does, errors and what nots?
// Jason Rodriguez
// CE335 Cubic Spline
//Homework # 7
#include<iostream.h>
#include<math.h>
int main ()
{
float t[20], x[20], y[20], b[20], h[20], U[20], V[20], Z[20], A[20], B[20], C[20], D[20], S[20];
int n, i;
cout <<”\n Enter the value for N: “;
cin >>n;
for (i=0; i<=n; i++)
{
cout<<” \n Enter the value for T” <<i<<”:”;
cin >>t[i];
}
cout<<endl<<endl;
for (i=0; i<=n; i++)
{
y[i] = 1 / (1+ pow(t[i],2));
cout<<”\n Y” <<i<<”=”<<y[i]<<endl<<endl;
}
for (i=0; i<=n-1; i++)
{
h[i] = t[i+1] – t[i];
b[i] = (1/h[i]) * (y[i+1] + h[i]);
}
cout<<endl;
for (i=0; i<=1; i++)
{
U[i+1] = 2 * (h[i+1]);
V[i+1] = 6 * (b[i+1]);
}
cout<<endl;
for (i=0; i<=n-1; i++)
{
U[i+1] = (2 * (h[i] + (h[i-1])) - (pow(h[i-1], 2) / U[i-1]);
V[i+1] = (6 * (b[i] - (b[i])) - ((h[i-1] * V[i-1])); // U[i-1]);
}
cout<<endl;
for (i=0; i<=1; i++)
{
z[i] = 0;
z[n] = 0;
}
cout<<endl;
for(i=n-1; i<=1; i--)
{
Z[i] = ((V[i] - (h[i] * Z[i+1]))/ U[i]);
}
cout<<endl<<endl<<endl;
for ( i=0; i<=n; i++)
{
A[i] = y[i];
B[i] = ((-h[i] * Z[i+1])/6) - ((h[i] * Z[i])/3) + ((1/h[i]) * (y[i+1] - y[i]));
C[i] = Z[i]/2;
D[i] = (1/(6* h[i])) * (Z[i+1] - Z[i]);
}
cout<<endl;
for (i=0; i<n-1; i++)
{
x[i] = t[i];
S[i] = A[i] + (B[i] * (X[i] - t[i])) + C[i] * pow((x[i] - t[i], 2)) + (D[i] * pow((x[i] - t[i]), 3));
cout<<"\n S" <<i <<"(x)=" <<S[i];
}
cout<<endl<<endl;
return 0;
}
// Jason Rodriguez
// CE335 Cubic Spline
//Homework # 7
#include<iostream.h>
#include<math.h>
int main ()
{
float t[20], x[20], y[20], b[20], h[20], U[20], V[20], Z[20], A[20], B[20], C[20], D[20], S[20];
int n, i;
cout <<”\n Enter the value for N: “;
cin >>n;
for (i=0; i<=n; i++)
{
cout<<” \n Enter the value for T” <<i<<”:”;
cin >>t[i];
}
cout<<endl<<endl;
for (i=0; i<=n; i++)
{
y[i] = 1 / (1+ pow(t[i],2));
cout<<”\n Y” <<i<<”=”<<y[i]<<endl<<endl;
}
for (i=0; i<=n-1; i++)
{
h[i] = t[i+1] – t[i];
b[i] = (1/h[i]) * (y[i+1] + h[i]);
}
cout<<endl;
for (i=0; i<=1; i++)
{
U[i+1] = 2 * (h[i+1]);
V[i+1] = 6 * (b[i+1]);
}
cout<<endl;
for (i=0; i<=n-1; i++)
{
U[i+1] = (2 * (h[i] + (h[i-1])) - (pow(h[i-1], 2) / U[i-1]);
V[i+1] = (6 * (b[i] - (b[i])) - ((h[i-1] * V[i-1])); // U[i-1]);
}
cout<<endl;
for (i=0; i<=1; i++)
{
z[i] = 0;
z[n] = 0;
}
cout<<endl;
for(i=n-1; i<=1; i--)
{
Z[i] = ((V[i] - (h[i] * Z[i+1]))/ U[i]);
}
cout<<endl<<endl<<endl;
for ( i=0; i<=n; i++)
{
A[i] = y[i];
B[i] = ((-h[i] * Z[i+1])/6) - ((h[i] * Z[i])/3) + ((1/h[i]) * (y[i+1] - y[i]));
C[i] = Z[i]/2;
D[i] = (1/(6* h[i])) * (Z[i+1] - Z[i]);
}
cout<<endl;
for (i=0; i<n-1; i++)
{
x[i] = t[i];
S[i] = A[i] + (B[i] * (X[i] - t[i])) + C[i] * pow((x[i] - t[i], 2)) + (D[i] * pow((x[i] - t[i]), 3));
cout<<"\n S" <<i <<"(x)=" <<S[i];
}
cout<<endl<<endl;
return 0;
}
#7
[quote name='drftk1d' date='Apr 19 2005, 12:34 PM']maybe he is just taking the class at school and didnt want to pay $100 for a verision of c++?
[/quote]
Just a thought.
[snapback]701911[/snapback]
[/quote]
Just a thought.
#8
[quote name='Dysfnctnl85' date='Apr 19 2005, 09:10 AM']Ummm, how can you take c++ and not have a c compiler?!
[/quote]
school has a compiler,
I dont have a computer my computer burnt to the ground im using my girls computer. Plus im doing civil engineering but this CE class we have to use C++ to solve CE problems
[snapback]701904[/snapback]
[/quote]
school has a compiler,
I dont have a computer my computer burnt to the ground im using my girls computer. Plus im doing civil engineering but this CE class we have to use C++ to solve CE problems
#9
I had a similar problem. Project was due after spring break, I had the project done but no compiler. Emailed the instructor, got a link to Borland to use the free 90-day trial of their compiler, and they emailed me the wrong serial number and passcode! 3 TIMES! I couldn't do any of the work at home, and had no time to go to school during the computer lab's open hours... ended up having to drop the class.
#10
[quote name='Tessai' date='Apr 19 2005, 12:19 PM']I had a similar problem. Project was due after spring break, I had the project done but no compiler. Emailed the instructor, got a link to Borland to use the free 90-day trial of their compiler, and they emailed me the wrong serial number and passcode! 3 TIMES! I couldn't do any of the work at home, and had no time to go to school during the computer lab's open hours... ended up having to drop the class.
[/quote]
Ouch that sucks balllz..
[snapback]701986[/snapback]
[/quote]
Ouch that sucks balllz..