Hello world!! That's what i frst learned at programing. But now i have advanced a little and i have some problems so i come to you experienced programers hoping that you can help me. My program is to find every abcd(uplined) number which divided to an input n gives an integer result. the digits a b c d are diferent.My code looks like this.
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main(int argc, char *argv[])
{
int n, a=0, b=0,c=0,d=0, num, i, g;
cin>>n;
for(num=0, num<10000, num++)
{i=num;
d=num%10;
num=num/10;
c=num%10;
num=num/10;
b=num%10;
num=num/10;
a=num%10;
if(i%n=0&&a!=b&&a!=c&&!=d&&b!=c&&b!=d&&c!=d)
{g=1000*a+100*b+10*c+d;
cout<<g<<endl;};};
system("PAUSE");
return EXIT_SUCCESS;
}
But unfortunely i have some errors that don't let my program work. The errors are :
10 C:\... expected `;' before ')' token
23 C:\... expected primary-expression before "return"
23 C:\... expected `)' before "return"
If you think you can please give me a hand and solve these errors. Thabk you!
how good are you with java? I'm having some troubles creating a simon says game. i have an hour and a half to finish it, i'm running on nothing but monster drinks and no sleep, and this is the only thing keeping me from getting my associates degree in computer science. Can you help?
Thank you for all the help provided. It helped me solving some errors AND savig some space but i still have one error an it is:
19 C:\... non-lvalue in assignment
on the folowing code:
It's all good, ask as many questions as you can now because the basics are the most important when starting with C++. Most of the people here are very helpful.
Another note. Lets take n==10. Is num==10 a valid answer? Code says "no".
d==0
c==1
b==0
a==0
One can argue that there is no hundreds and thousands in 10, and non-existing 'a' is not equal to non-existing 'b' is not equal to 'd', which exists and is 0. The code does not handle the num<1000 as special cases.