|
-
December 14th, 2013, 03:04 PM
#1
need a little help
Heyy!
I just started learning programing and there is a little assigment that i need to do, but i cant figure out why my program is not doing what it should do. If i look at it, everything seems correct, but when i try to run it, it never stops.
I have to find minimal number m, where m=a^3+b^3=c^3+d^3. It should print out 1729, but it doesnt.
No idea how to fix this.    
Code:
#include <iostream>
using namespace std;
int maks(int num1, int num2);
int main()
{
int atgr,m,n,sk=100;
for (int k=1; k<=sk; k++){
for (int l=1; l<=sk; l++){
for (int i=1; i<=sk; i++){
for (int j=1; j<=sk; j++){
m= k*k*k + l*l*l;
n= j*j*j + i*i*i;
if(k!=l && k!=i && k!=j && l!=i && l!=j && i!=j){
cout<<atgr;}
}
}
}
};
atgr=maks(m,n);
}
int maks(int num1, int num2){
int m;
if (num1==num2) m=num1;
return m;
}
-
December 14th, 2013, 04:20 PM
#2
Re: need a little help
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|