Experiment two, 04 Peng Yuan

Source: Internet
Author: User

#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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.