Need Help..!!

Reply

Join Date: Dec 2008
Posts: 1
Reputation: alunsandro is an unknown quantity at this point 
Solved Threads: 0
alunsandro alunsandro is offline Offline
Newbie Poster

Need Help..!!

 
0
  #1
Jan 4th, 2009
Hi Everyone..!!

I'm a newcomer here. And looks like need your help here. I 've just make a program tha simulates The HRN CPU Scheduler.I have no problem in compiling it. But, when I run it, It won't work.


I don't know which Part of my pseudocode that was wrong. Could someone help me to solve it, please..!


Here's the pseudocode

  
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <math.h>
  4. #include <iomanip.h>
  5.  
  6. typedef struct
  7. {
  8. float Prioritas;
  9. int Waiting;
  10. int Lama;
  11. int TA;
  12. char ID;
  13. }Penjadwalan;
  14.  
  15. typedef Penjadwalan Proses[6];
  16.  
  17. void main()
  18. {
  19. Proses HRN;
  20. int i,j,time,Min;
  21. float Max;
  22.  
  23.  
  24. /*INPUT PROSES*/
  25.  
  26. HRN[1].ID = 'A';
  27. HRN[1].Lama= 12;
  28.  
  29. HRN[2].ID = 'B';
  30. HRN[2].Lama= 57;
  31.  
  32. HRN[3].ID = 'C';
  33. HRN[3].Lama= 32;
  34.  
  35. HRN[4].ID = 'D';
  36. HRN[4].Lama= 10;
  37.  
  38. HRN[5].ID = 'E';
  39. HRN[5].Lama= 40;
  40.  
  41.  
  42. /******************/
  43.  
  44.  
  45. /*Menampilkan hasil input*/
  46. printf("Sebelum\n");
  47.  
  48. for (i=1; i<6; i++)
  49. { HRN[i].Waiting = 0;
  50. printf("ID : %c\n",HRN[i].ID);
  51. printf("Layanan : %d\n",HRN[i].Lama);
  52. printf("Waiting : %d\n\n",HRN[i].Waiting);
  53. }
  54. getch();
  55. /******************/
  56.  
  57. clrscr();
  58.  
  59. /*Melakukan Eksekusi HRN*/
  60. time=0;
  61. for (i=1; i<6; i++)
  62. {
  63. /*Jika wktu belum berjalan cari Lama dgn wkt terkecil*/
  64. if ( time == 0 )
  65. {
  66. /*PROSEDUR untuk mencari Min*/
  67. Min = HRN[1].Lama;
  68. for (j=2; j<6; j++)
  69. {
  70. if ( Min > HRN[j].Lama )
  71. {
  72. Min = HRN[j].Lama;
  73. }
  74. }
  75. /******************************************************/
  76. for(j=1; j<6; j++)
  77. {
  78. if (Min == HRN[j].Lama)
  79. {
  80. time=time+HRN[j].Lama;
  81. HRN[j].Lama=0;
  82. printf("Proses '%c' Telah Di eksekusi\n\n", HRN[j].ID);
  83. }
  84. }
  85. printf("Waktu Sekarang: %d\n\n",time);
  86. }
  87. /*****************************************************************/
  88. else
  89. { printf("Perputaran ke-%d\n\n",i);
  90. for (j=1; j<6; j++)
  91. {
  92. HRN[j].Waiting=time+HRN[j].Waiting;
  93. HRN[j].Prioritas = (HRN[j].Waiting + HRN[j].Lama)/ HRN[j].Lama;
  94. printf("Proritas Proses '%c' = %f\n\n",HRN[j].ID,HRN[j].Prioritas);
  95. }
  96.  
  97. /*PROSEDUR untuk mencari Prioritas Terbesar*/
  98. Max=HRN[1].Prioritas;
  99. for (j=2;j<6;j++)
  100. {
  101. if ( Max < HRN[j].Prioritas )
  102. {
  103. Max = HRN[j].Prioritas;
  104. }
  105. }
  106. /*******************************************/
  107.  
  108. for(j=1; j<6; j++)
  109. {
  110. if (Max == HRN[j].Prioritas)
  111. {
  112. time=time+HRN[j].Lama;
  113. HRN[j].Lama=0;
  114. printf("Proses '%c' Telah Di eksekusi", HRN[j].ID);
  115. }
  116. }
  117.  
  118.  
  119. }
  120. }
  121. /******************/
  122.  
  123. }

cOZ I'm an Indonesian. There're Lots of sentences using Bahasa Indonesia there...


Anyway, Thanks 4 ur attention..!!
Attached Files
File Type: c hrn.c (2.2 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Need Help..!!

 
0
  #2
Jan 4th, 2009
iomanip.h is c++, not c, so you should delete that line (line #4)
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



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