Guest User

Untitled

a guest
Apr 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2. struct process
  3. {
  4. char name[10];
  5. int arrival_time;
  6. int burst_time;
  7. }p[10];
  8. void main()
  9. {
  10. int i,b,j,sum_of_busttime=0;
  11. printf("Enter the number of processes:");
  12. scanf("%d",&b);
  13. printf("enter the details of the process:\n");
  14. printf("P_Name\tA_Time\tB_time\n");
  15. for(i=0;i<b;i++)
  16. {
  17. scanf("%s%d%d",&p[i].name,&p[i].arrival_time,&p[i].burst_time);
  18. sum_of_busttime+=p[i].burst_time;
  19. }
  20. struct process temp;
  21. for(i=0;i<b-1;i++)
  22. {
  23. for(j=i+1;j<b;j++)
  24. {
  25. if(p[i].arrival_time>p[j].arrival_time)
  26. {
  27. temp=p[i];
  28. p[i]=p[j];
  29. p[j]=temp;
  30. }
  31. }
  32. }
  33. printf("P_Name\tA_Time\tB_time\n");
  34. for(i=0;i<b;i++)
  35. {
  36. printf("%s\t%d\t%d\n",p[i].name,p[i].arrival_time,p[i].burst_time);
  37. }
  38. printf("%d",sum_of_busttime);
  39. }
Add Comment
Please, Sign In to add comment