|
From: Scone S. <sc...@ho...> - 2001-01-06 17:54:47
|
The program below causes an error on my computer, but I don't know what it
could be.
Does anyone know?
Thanks, Scone
============================
#include <iostream>
#include <stdlib.h>
int main ()
{
cout << "This program reads a number and calculates all rows of two or
more\n";
cout << "successive numbers of which the sum equals this number.\n";
cout << "E.g.: 15 = 1+2+3+4+5 = 4+5+6 = 7+8\n\n";
unsigned s, t, u, x, y, z;
cout << "Type a random number and press enter: ";
cin >> s;
cout << endl;
unsigned a[(s/2)+1];
for(x=1;x++;x<=((s/2)+1))
{ y=1;
for(u=1;u++;u<=((s/2)+1))
{ a[u]=0;
}
u=x;
while(1)
{ a[y++]=u++;
t=0;
for(z=1;z++;z<=y)
{ t+=a[z];
}
if (t<=s) break;
}
cout << s << " = ";
for(u=1;u++;u<=((s/2)+1))
{ cout << a[u] << " + ";
}
cout << endl;
}
system("pause");
return 0;
}
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
|