This code works fine without the if loops, but when I add them it just goes forever. I was simply trying to fix the matrix to make it evenly spaced, anyone know how I could do it??
#include <iostream>
#include <math.h>
using namespace std;
double Fun (double iX, double iY)
{return sqrt(iX*iX+iY*iY);}
int main (void)
{double iX =1.0, iY=1.0;
cout << "\t 1\t2\t\t3\t\t4\t\t5"<<endl;
cout <<"1\t";
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
cout <<"2\t";
iY=2.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
cout <<"3\t";
iY=3.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;
if (iX==4){cout << "\t" ;}}
cout <<"\n4\t";
iY=4.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;
if ((iX==3)||(iX=4)){cout << "\t" ;}}
cout <<"\n5\t";
iY=5.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
return 1;}
Bourgond is pleading of you to use the code tags (<>) button to the right. It will make your code much easier to see. Also, don't forget to indent your code.