Can you help me?? I'm at wit's end with this matrix

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;}
Last edited on
Use
[code][/code]
tags.
This may be a ridiculous question, but what are those? How could I use them to fix this code?
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.

Example of code tage use:
[code]
int main(){
   std::cout << "Hello world!" << std::endl;
   return 0;
}
[/code]

Produces:
1
2
3
4
int main(){
   std::cout << "Hello world!" << std::endl;
   return 0;
}


It really would help everyone out if you put your code in code tags.
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
33
34
35
36
37
#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;}

if ((iX==3)||(iX=4)){cout << "\t" ;}} iX=4 U NEED ==
:D :P
omg YES! I knew it was something stupid like that... Good eye topnik1!!
xd
Topic archived. No new replies allowed.