//challenge,, fix this!

#include<stdio.h>
#include<conio.h>

void main()
{
struct job{
int at;
int bt;
};
struct job J[80], cpy[80], temp, cpy2[80];
int q, oh, jbn, x, y, z, t, ref=0, tt[80];
again:
clrscr();
textcolor(YELLOW);
gotoxy(20,5); cprintf("*** ROUND ROBIN WITH OVERHEAD ALGORITHM ***");
textcolor(10);
gotoxy(5,7); cprintf("How many jobs do you want to enter?(max 15 jobs)   ");
scanf("%d", &jbn);
if(jbn>15)
{
printf("\tThe maximum jobs that can be entered is 15. Please try again.\n");
printf("\tPress enter");
getch();
goto again;}
else
{
gotoxy(10,9); printf("Please fill out the following arrival time and burst time");
gotoxy(15,11); printf("Job          Arrival time          Burst time");
y=11;
for(x=1;x<=jbn;x++)
{y=y+2;
 gotoxy(16,y);printf("J%d",x);
 gotoxy(33,y); scanf("%d",&J[x-1].at);
 gotoxy(54,y); scanf("%d",&J[x-1].bt);}//end for
y=y+2;
gotoxy(10,y); printf("Please enter the quantum time:\t");
scanf("%d",&q);
y=y+2;
gotoxy(10,y); printf("Please enter the overhead time:\t");
scanf("%d",&oh);
y=y+2;
gotoxy(10,y);
puts("All the datas are inputted. Please press enter");
getch();
for(x=0;x<jbn;x++)
{cpy[x].at=J[x].at;
 cpy[x].bt=J[x].bt;}
for(x=jbn-1;x>=0;x--)
 {for(z=1;z<=x;z++)
    {if(cpy[x].at<cpy[x-z].at)
       {temp.at=cpy[x].at;
	temp.bt=cpy[x].bt;
	cpy[x].at=cpy[x-z].at;
	cpy[x].bt=cpy[x-z].bt;
	cpy[x-z].at=temp.at;
	cpy[x-z].bt=temp.bt;}//end if
      }//end for1
 }//end for2
printf("\n");
for(x=0;x<jbn;x++)
  ref=ref+cpy[x].bt;
for(x=0;x<jbn;x++)
{cpy2[x].at=cpy[x].at;
 cpy2[x].bt=cpy[x].bt;}
x=0;
printf("Gantt Chart:\n\n");
for(t=0;t<=ref;t++)
  {printf("|");
   z=0;
   while(cpy[x].at!=J[z].at&&cpy[x].bt!=J[z].bt)
     z++;
   printf(" J%d (%d)",z+1,J[z].bt);
   t=t+J[z].bt;
   tt[x]=t;
   t--;
   x++;}
printf("|\n");
printf("Turnaround Time\n");
for(x=0;x<jbn;x++)
 {printf("tt = %d - %d",tt[x]+cpy[0].at, cpy[x].at);
  tt[x]=tt[x]-cpy[x].at+cpy[0].at;
  printf(" = %d\n",tt[x]);}
printf("Waiting Time\n");
for(x=0;x<jbn;x++)
 {printf("wt = %d - %d",tt[x],cpy[x].bt);
  tt[x]=tt[x]-cpy[x].bt;
  printf(" = %d\n",tt[x]);}

  printf("%dcpy.at %dJ.at %dcpy2.at ",cpy[1].at,J[1].at,cpy2[1].at);
   printf("%dcpy.bat %dJ.bat %dcpy2.bat ",cpy[2].bt,J[1].bt,cpy2[1].bt);




getch();}//end else

}//end main

Recommended Answers

All 4 Replies

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.

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

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

the first challenge for you is to read and understand the instructions that are required to be followed here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.