#include <stdio.h>#definen 20structfcfs{intId//Process Name intGt//Process Arrival Time intRunt//Process Run Time intFt//Process Finish Time intRt//Process Turnaround Time}f[n];voidMain () {intamount,i,j,l,k; structFcfs F[n]; printf ("Please enter the number of processes: \ n"); scanf ("%d",&amount); for(i=0; i<amount;i++) {printf ("Please enter the process name, process arrival time, process run time: \ n"); scanf ("%d",&f[i].id); scanf ("%d",&f[i].gt); scanf ("%d",&f[i].runt); } for(i=0; i<amount;i++)//sequencing by process arrival time{//If two processes arrive at the same time, press ENTER first on the screen to run for(j=0; j<amount-i-1; j + +) { if(f[j].gt>f[j+1].gt) {L=f[j].gt; F[J].GT=f[j+1].gt; F[j+1].gt=l; K=f[j].id; F[j].id=f[j+1].id; F[j+1].id=K; } } } for(i=0; i<amount;i++) {f[i].ft=f[i].gt+F[i].runt; F[i].rt=f[i].ft-f[i].gt; printf ("process%d starts from%d and ends before%d \ n", f[i].id,f[i].gt,f[i].ft); F[i+1].gt=f[i].ft; printf ("turnaround time is%d\n", F[I].RT); }}
Summary: This experiment, in fact, the dispatch of what, do not know what the meaning of the Internet reference after the feeling is still good, but with the C language before the same, the overall understanding is not difficult, but there are many shortcomings, to continue to learn.
Experiment two, 04 Peng Yuan