Need Help Immediatedly Please

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Need Help Immediatedly Please

 
0
  #1
May 13th, 2008
Please help me in doing this problem in C++ without filing

______________________________________________________________________
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. #define min(a,b)((a)<(b)?(a):(b))
  5. int a[6000];
  6. main()
  7. {
  8. file*input=fopen("number.in","r");
  9. int n,p2,p3,p5,p7;
  10. a[1]=n=p2=p3=p5=p7=1;
  11. while (a[n]<2000000000)
  12. {
  13. a[1+n]=min4(2*a[p2],3*a[p3],5*a[p5],7*a[p7]);
  14. if (a[n]==2*a[p2]) p++;
  15. if (a[n]==3*a[p3]) p++;
  16. if (a[n]==5*a[p5]) p++;
  17. if (a[n]==7*a[p7]) p++;
  18. }
  19. {
  20. fscanf(input,"%d",&n);
  21. if (n==0) break;
  22. printf("the%d",n);
  23. if (n%10==1&& n/10% 10!=1)
  24. printf("st");
  25. else if(n%10==2&& n/10% 10!=1)
  26. printf("nd");
  27. else
  28. if(n%10==3&& n/10% 10!==1)
  29. printf("rd");
  30. else
  31. printf("th")
  32. printf("humble number is %d\n",a[n]);
  33. }
  34. fclose(input);
  35. return 0;
  36. }
Last edited by Ancient Dragon; May 13th, 2008 at 9:39 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Need Help Immediatedly Please

 
0
  #2
May 13th, 2008
What is it that u need help with, what the project is doing, where are u stucked with the project.....sure everybody would like to know that hey
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Re: Need Help Immediatedly Please

 
0
  #3
May 13th, 2008
sorry i forgot to mention that the project is that user enters a number and the programme return a humble number
e.g
user enters 3;
the program should return the 3rd humble number
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,839
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 298
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: Need Help Immediatedly Please

 
0
  #4
May 13th, 2008
A few things come to my attention:

  1. int n,p2,p3,p5,p7;
  2. a[1]=n=p2=p3=p5=p7=1;
That's awful, what are you doing here?
  1. while (a[n]<2000000000)
  2. {
You never increase n, so it will always write in the same element,
Besides: You declared 'a' as an array of 6000 ints, so there's no room for 2000000000 numbers.
  1. {
  2. fscanf(input,"%d",&n);
What's the bracket for?

And that's just the tip of the iceberg, but before I continue:

Use code tags and indent your code. Then as a clear question about it.

[edit] And about main()
Last edited by niek_e; May 13th, 2008 at 8:38 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 109
Reputation: architact is an unknown quantity at this point 
Solved Threads: 7
architact's Avatar
architact architact is offline Offline
Junior Poster

Re: Need Help Immediatedly Please

 
0
  #5
May 13th, 2008
please forget the code what i want to do is that user enters a number from keyboard the program in ouput displays the humble number
Example:
input = 5842
output = the 5842nd humble number is 2000000000
If you think we fight for money and you fight for honor, then remember everyone fights for the thing they don't have...
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 33
Reputation: DigitalPackrat is an unknown quantity at this point 
Solved Threads: 1
DigitalPackrat's Avatar
DigitalPackrat DigitalPackrat is offline Offline
Light Poster

Re: Need Help Immediatedly Please

 
0
  #6
May 13th, 2008
The first thing that you have to do is find all the prime numbers except 2, 3, 5 and 7 till the number which is input. Then check if the prime numbers is a factor of the number. If it is not its humble.
[Catchy Signature Here]
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC