| | |
Need Help Immediatedly Please
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Please help me in doing this problem in C++ without filing
______________________________________________________________________
______________________________________________________________________
C++ Syntax (Toggle Plain Text)
#include<iostream.h> #include<conio.h> #include<stdio.h> #define min(a,b)((a)<(b)?(a):(b)) int a[6000]; main() { file*input=fopen("number.in","r"); int n,p2,p3,p5,p7; a[1]=n=p2=p3=p5=p7=1; while (a[n]<2000000000) { a[1+n]=min4(2*a[p2],3*a[p3],5*a[p5],7*a[p7]); if (a[n]==2*a[p2]) p++; if (a[n]==3*a[p3]) p++; if (a[n]==5*a[p5]) p++; if (a[n]==7*a[p7]) p++; } { fscanf(input,"%d",&n); if (n==0) break; printf("the%d",n); if (n%10==1&& n/10% 10!=1) printf("st"); else if(n%10==2&& n/10% 10!=1) printf("nd"); else if(n%10==3&& n/10% 10!==1) printf("rd"); else printf("th") printf("humble number is %d\n",a[n]); } fclose(input); return 0; }
Last edited by Ancient Dragon; May 13th, 2008 at 9:39 am. Reason: add code tags
A few things come to my attention:
That's awful, what are you doing here?
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.
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()
C++ Syntax (Toggle Plain Text)
int n,p2,p3,p5,p7; a[1]=n=p2=p3=p5=p7=1;
C++ Syntax (Toggle Plain Text)
while (a[n]<2000000000) {
Besides: You declared 'a' as an array of 6000 ints, so there's no room for 2000000000 numbers.
C++ Syntax (Toggle Plain Text)
{ fscanf(input,"%d",&n);
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.
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
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...
![]() |
Similar Threads
- want a help in MATLAB ? (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: linked list insertion problem
- Next Thread: Need advice on shortest path algorithms
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






