DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   Need Help..!! (http://www.daniweb.com/forums/thread165990.html)

alunsandro Jan 4th, 2009 11:48 am
Need Help..!!
 
1 Attachment(s)
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.
:S

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

Here's the pseudocode

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

typedef struct
{
        float Prioritas;
        int Waiting;
        int Lama;
        int TA;
        char ID;
}Penjadwalan;

typedef Penjadwalan Proses[6];

void main()
{
        Proses HRN;
        int i,j,time,Min;
        float Max;


        /*INPUT PROSES*/

        HRN[1].ID = 'A';
        HRN[1].Lama= 12;

        HRN[2].ID = 'B';
        HRN[2].Lama= 57;

        HRN[3].ID = 'C';
        HRN[3].Lama= 32;

        HRN[4].ID = 'D';
        HRN[4].Lama= 10;

        HRN[5].ID = 'E';
        HRN[5].Lama= 40;


        /******************/


        /*Menampilkan hasil input*/
        printf("Sebelum\n");

        for (i=1; i<6; i++)
        {  HRN[i].Waiting = 0;
                printf("ID        : %c\n",HRN[i].ID);
                printf("Layanan   : %d\n",HRN[i].Lama);
                printf("Waiting   : %d\n\n",HRN[i].Waiting);
        }
        getch();
        /******************/

   clrscr();

        /*Melakukan Eksekusi HRN*/
        time=0;
        for (i=1; i<6; i++)
        {
                /*Jika wktu belum berjalan cari Lama dgn wkt terkecil*/
                if ( time == 0 )
                {
                        /*PROSEDUR untuk mencari Min*/
                        Min = HRN[1].Lama;
                        for (j=2; j<6; j++)
                        {
                          if ( Min > HRN[j].Lama )
                          {
                                        Min  = HRN[j].Lama;
                          }
                        }
                        /******************************************************/
                        for(j=1; j<6; j++)
                        {
                                if (Min == HRN[j].Lama)
                                {
                                        time=time+HRN[j].Lama;
                                        HRN[j].Lama=0;
                                        printf("Proses '%c' Telah Di eksekusi\n\n", HRN[j].ID);
                                }
                        }
                        printf("Waktu Sekarang: %d\n\n",time);
                }
                /*****************************************************************/
                else
                {  printf("Perputaran ke-%d\n\n",i);
                        for (j=1; j<6; j++)
                        {
                          HRN[j].Waiting=time+HRN[j].Waiting;
                          HRN[j].Prioritas = (HRN[j].Waiting + HRN[j].Lama)/ HRN[j].Lama;
                          printf("Proritas Proses '%c' = %f\n\n",HRN[j].ID,HRN[j].Prioritas);
                        }

                        /*PROSEDUR untuk mencari Prioritas Terbesar*/
                        Max=HRN[1].Prioritas;
                        for (j=2;j<6;j++)
                        {
                                if ( Max < HRN[j].Prioritas )
                                {
                                        Max = HRN[j].Prioritas;
                                }
                        }
                        /*******************************************/

                        for(j=1; j<6; j++)
                        {
                                if (Max == HRN[j].Prioritas)
                                {
                                        time=time+HRN[j].Lama;
                                        HRN[j].Lama=0;
                                        printf("Proses '%c' Telah Di eksekusi", HRN[j].ID);
                                }
                        }


                }
        }
        /******************/

}

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

Anyway, Thanks 4 ur attention..!!:)

Ancient Dragon Jan 4th, 2009 3:34 pm
Re: Need Help..!!
 
iomanip.h is c++, not c, so you should delete that line (line #4)


All times are GMT -4. The time now is 10:52 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC