C/C++ simple challenge

Status
Not open for further replies.

alib_i

Cyborg Agent
f00k u prankzter ..
its not any 11th class homework

this question was asked in an all-india c/c++ programming contest 3yrs back....
the only problem is that i dont remember the question properly.
and dont know the right answer too.

and to tell u ..
im not in 11th ..
im in 4th yr of my college ..
see how angry i am
<----------------------
:eek: :eek:
 

DKant

In the zone
Anybody done the magic square thingy? (It was something like sum of all rows/cols/diags of an nxn matrix is the same...I don't remember exactly. U have to build that matrix of course)

I haven't thought a lot about it..How do we implement it? Iterative methods? Remember this was just one question in a 3 hour/so C++ challenge.
 

NikhilVerma

Padawan
Actually tere is a prescribed method for making that square...

One of my freinds made that program ... Maybe I could get it from him... or make my own...

BTW check these out

*math.nmsu.edu/breakingaway/Lessons/magicsquare1/magicsquare.html
*www.math.hmc.edu/funfacts/ffiles/10001.4-8.shtml
 

vysakh

Padawan
try this
//program to print the numbers in a triangle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int ar[10][10],n,i,j;
cout<<"Enter number of rows:";
cin>>n;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
ar[j]=0;
cout<<"The pascal triangle for "<<n<<" rows is :\n";
for(i=0;i<n;i++)
{
cout<<"\n";
ar[0]=1;
for(j=0;j<=i;j++)
{
cout<<ar[j]<<"\t";
ar[i+1][j+1]=ar[j]+ar[j+1];
}
}
getch();
}
 

jcmac

Broken In
#include<iostream.h>
void main()
{
int a,b,c;
cout<<"enter 2 numbers";
cin>>a,b;
c=a+b;
cout<<"first number :"<<c-a;
cout<<"second number :"<<c-b;
}
 

jcmac

Broken In
#include<iostream.h>
void main()
{
int a,b,c;
cout<<"enter 2 numbers";
cin>>a,b;
c=a+b;
cout<<"first number :"<<c-a;
cout<<"second number :"<<c-b;
}
 

zahirdhada

Right off the assembly line
One line code for swapping two variables, a and b, without using third variable

a^=b^=a^=b

the above line of code will swap values of a and b
 
Status
Not open for further replies.
Top Bottom