pls fix this.....

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 6
Reputation: patricksquare is an unknown quantity at this point 
Solved Threads: 0
patricksquare patricksquare is offline Offline
Newbie Poster

pls fix this.....

 
0
  #1
Oct 4th, 2008
//challenge,, fix this!
  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
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 305
Reputation: stilllearning has a spectacular aura about stilllearning has a spectacular aura about 
Solved Threads: 43
stilllearning stilllearning is offline Offline
Posting Whiz

Re: pls fix this.....

 
0
  #2
Oct 4th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 6
Reputation: patricksquare is an unknown quantity at this point 
Solved Threads: 0
patricksquare patricksquare is offline Offline
Newbie Poster

Re: pls fix this.....

 
0
  #3
Oct 4th, 2008
wow challenging
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: pls fix this.....

 
0
  #4
Oct 4th, 2008
Yeah, the first challenge is for you to read the introduction threads, such as

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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 89
Reputation: bhoot_jb is on a distinguished road 
Solved Threads: 2
bhoot_jb bhoot_jb is offline Offline
Junior Poster in Training

Re: pls fix this.....

 
0
  #5
Oct 4th, 2008
the first challenge for you is to read and understand the instructions that are required to be followed here.
Bhoot
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
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