943,898 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 584
  • C++ RSS
Oct 4th, 2008
0

pls fix this.....

Expand Post »
//challenge,, fix this!
C++ Syntax (Toggle Plain Text)
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. void main()
  5. {
  6. struct job{
  7. int at;
  8. int bt;
  9. };
  10. struct job J[80], cpy[80], temp, cpy2[80];
  11. int q, oh, jbn, x, y, z, t, ref=0, tt[80];
  12. again:
  13. clrscr();
  14. textcolor(YELLOW);
  15. gotoxy(20,5); cprintf("*** ROUND ROBIN WITH OVERHEAD ALGORITHM ***");
  16. textcolor(10);
  17. gotoxy(5,7); cprintf("How many jobs do you want to enter?(max 15 jobs) ");
  18. scanf("%d", &jbn);
  19. if(jbn>15)
  20. {
  21. printf("\tThe maximum jobs that can be entered is 15. Please try again.\n");
  22. printf("\tPress enter");
  23. getch();
  24. goto again;}
  25. else
  26. {
  27. gotoxy(10,9); printf("Please fill out the following arrival time and burst time");
  28. gotoxy(15,11); printf("Job Arrival time Burst time");
  29. y=11;
  30. for(x=1;x<=jbn;x++)
  31. {y=y+2;
  32. gotoxy(16,y);printf("J%d",x);
  33. gotoxy(33,y); scanf("%d",&J[x-1].at);
  34. gotoxy(54,y); scanf("%d",&J[x-1].bt);}//end for
  35. y=y+2;
  36. gotoxy(10,y); printf("Please enter the quantum time:\t");
  37. scanf("%d",&q);
  38. y=y+2;
  39. gotoxy(10,y); printf("Please enter the overhead time:\t");
  40. scanf("%d",&oh);
  41. y=y+2;
  42. gotoxy(10,y);
  43. puts("All the datas are inputted. Please press enter");
  44. getch();
  45. for(x=0;x<jbn;x++)
  46. {cpy[x].at=J[x].at;
  47. cpy[x].bt=J[x].bt;}
  48. for(x=jbn-1;x>=0;x--)
  49. {for(z=1;z<=x;z++)
  50. {if(cpy[x].at<cpy[x-z].at)
  51. {temp.at=cpy[x].at;
  52. temp.bt=cpy[x].bt;
  53. cpy[x].at=cpy[x-z].at;
  54. cpy[x].bt=cpy[x-z].bt;
  55. cpy[x-z].at=temp.at;
  56. cpy[x-z].bt=temp.bt;}//end if
  57. }//end for1
  58. }//end for2
  59. printf("\n");
  60. for(x=0;x<jbn;x++)
  61. ref=ref+cpy[x].bt;
  62. for(x=0;x<jbn;x++)
  63. {cpy2[x].at=cpy[x].at;
  64. cpy2[x].bt=cpy[x].bt;}
  65. x=0;
  66. printf("Gantt Chart:\n\n");
  67. for(t=0;t<=ref;t++)
  68. {printf("|");
  69. z=0;
  70. while(cpy[x].at!=J[z].at&&cpy[x].bt!=J[z].bt)
  71. z++;
  72. printf(" J%d (%d)",z+1,J[z].bt);
  73. t=t+J[z].bt;
  74. tt[x]=t;
  75. t--;
  76. x++;}
  77. printf("|\n");
  78. printf("Turnaround Time\n");
  79. for(x=0;x<jbn;x++)
  80. {printf("tt = %d - %d",tt[x]+cpy[0].at, cpy[x].at);
  81. tt[x]=tt[x]-cpy[x].at+cpy[0].at;
  82. printf(" = %d\n",tt[x]);}
  83. printf("Waiting Time\n");
  84. for(x=0;x<jbn;x++)
  85. {printf("wt = %d - %d",tt[x],cpy[x].bt);
  86. tt[x]=tt[x]-cpy[x].bt;
  87. printf(" = %d\n",tt[x]);}
  88.  
  89. printf("%dcpy.at %dJ.at %dcpy2.at ",cpy[1].at,J[1].at,cpy2[1].at);
  90. printf("%dcpy.bat %dJ.bat %dcpy2.bat ",cpy[2].bt,J[1].bt,cpy2[1].bt);
  91.  
  92.  
  93.  
  94.  
  95. getch();}//end else
  96.  
  97. }//end main
Last edited by Narue; Oct 4th, 2008 at 9:27 am. Reason: added code tags, no real help though with the crappy initial indentation
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
patricksquare is offline Offline
6 posts
since Oct 2008
Oct 4th, 2008
0

Re: pls fix this.....

First add code tags, and explain what your problem is. Also this looks like a C program, so you probably want to post it in the C forum.
Last edited by stilllearning; Oct 4th, 2008 at 6:01 am.
Reputation Points: 161
Solved Threads: 43
Posting Whiz
stilllearning is offline Offline
309 posts
since Oct 2007
Oct 4th, 2008
0

Re: pls fix this.....

wow challenging
Reputation Points: 10
Solved Threads: 0
Newbie Poster
patricksquare is offline Offline
6 posts
since Oct 2008
Oct 4th, 2008
0

Re: pls fix this.....

Yeah, the first challenge is for you to read the introduction threads, such as

Quote originally posted by board intro ...
Our Software Development forum category encompasses topics related to application programming and software design. When posting programming code, encase it in [code], [code=syntax], where 'syntax' is any language found within our Code Snippets section, or [icode], for inline code, bbcode tags. Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.
Our C++ forum is the place for Q&A-style discussions related to this popular language. Note we have a separate C forum for non-OOP straight C. Please direct C++ questions directly related to game development to our Game Development forum.
and http://www.daniweb.com/forums/announcement8-3.html
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Oct 4th, 2008
0

Re: pls fix this.....

the first challenge for you is to read and understand the instructions that are required to be followed here.
Reputation Points: 57
Solved Threads: 2
Junior Poster in Training
bhoot_jb is offline Offline
89 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Game of life in C++
Next Thread in C++ Forum Timeline: size of array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC