,   CyberForum.ru

Round Robin - C++

C++ http://www.cyberforum.ru/cpp-beginners/thread656396.html
, , , , . #include "stdafx.h" #include"iostream" #include<conio.h> #include<stdlib.h> #include<time.h> #include <iomanip>
C++ , . ? . . HIGHEST, IDLE, . , ? Visual Studio . #include "stdafx.h" #include "iostream" #include "windows.h" #include "stdlib.h" #include "time.h" #include... http://www.cyberforum.ru/cpp-beginners/thread656395.html
C++ STL sort()
sort() STL <algorithm>??
C++ "bool " #include <algorithm>? , ?
: #include "stdafx.h" #include <algorithm> #include <iostream> #include <conio.h> using namespace std; bool cmp(int x, int y) { return abs(x) < abs(y); }
C++ / , ( ) http://www.cyberforum.ru/cpp-beginners/thread656371.html
, . #define _USE_MATH_DEFINES #include <iostream> #include <cmath> #include <conio.h> using namespace std; int main(double, double);
C++ N n .

Rauan
0 / 0 / 0
: 05.12.2013
: 68
02.02.2014, 16:15     Round Robin
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream.h>
#include<stdlib.h>
int main()
{
int st[10], bt[10], wt[10], tat[10], n, tq; /* âðåìÿ âûïîë*å*èÿ, îæèä**èÿ, âûïîë*å*èÿ, êîëè÷åñòâî ïðîöåññîâ, êâ**ò âðåìå*è*/
int i, count=0, swt=0, stat=0, temp, sq=0; /* ïåðåìå**ûå äëÿ âûïîë*å*èÿ ïðîãð*ììû*/
float awt=0.0, atat=0.0; /* îáùåå âðåìÿ îæèä**èÿ è âûïîë*å*èÿ*/
cout<<"Vvedite kolichestvo processov: ";
cin>>n; /* Ââåäèòå êîëè÷åñòâî ïðîöåññîâ*/
for(i=0; i<n;i++) /* Öèêë ð**äîì*î ä*åò ç**÷å*èÿ âðåìå*è âûïî*å*èÿ*/
{
bt[i]=rand()%15;
st[i]=bt[i];
}
cout<<"Vvedite kvant vremeni: "; /* Ââîäèì êâ**ò âðåìå*è*/
cin>>tq; 
while(1) /* Öèêë ñîçä*åò î÷åðåäü â êîòîðîì ê*æäûé ïðîöåññ áóäåò èñïîëüçîâ*òü ÖÏÓ âðåìÿ îïðåäåëå**îå êâ**òîì âðåìå*è*/
{
for(i=0, count=0;i<n;i++) /* Öèêë äëÿ îïðåäåëå*èÿ *îìåð* ïðîöåññ**/
{
temp=tq;  
if(st[i]==0) /* Åñëè âðåìÿ âûïî*å*èÿ ð*â*î *óëþ ïåðåõîäèì ê ñëåä. ïðîöåññó*/
{
count++; 
continue;
}
if(st[i]>tq) /* Åñëè âðåìÿ âûïîë*å*èÿ áîëüøå êâ**ò* âðåìå*è, òî ó÷èòûâ*åì êâ**ò âðåìå*è îò âðåìå*è âûïîë*å*èÿ*/
{
st[i]=st[i]-tq;
}
else
if (st[i]>=0) 
{
temp=st[i];
st[i]=0;
}
sq=sq+temp; /* Âðåìÿ îáîðîò**/
tat[i]=sq; /* Âðåìÿ îæèä**èÿ*/
}
if(n==count) /* Åñëè êîëè÷åñòâî ïðîöåññîâ ç*êî*÷èòüñÿ, òî öèêë ç*êî*÷èòüñÿ*/
break; 
} /* Çäåñü êî*åö öèêë**/
for(i=0;i<n;i++) /* Ýòîò öèêë **õîäèò îáùåå âðåìÿ îæèä**èÿ è âûïîë*å*èÿ*/
{
wt[i]=tat[i]-bt[i];
swt=swt+wt[i];
stat=stat+tat[i];
}
awt=(float)swt/n;
atat=(float)stat/n;
/* Âûâîäèì ïîëó÷å**ûå ä***ûå ** ýêð** êî*ñîëè*/
cout<<endl<<"Process        CPU burst       Wait        Oborot";
/* Íîìåð ïðîöåññ*,Âðåìÿ âûïîë*å*èÿ(ñåðâèñ*),Âðåìÿ îæèä**èÿ,Âðåìÿ îáîðîò**/
cout<<endl;
cout<<endl;
for(i=0; i<n; i++)
{
cout<<i+1<<"\t\t"<<bt[i]<<"\t\t\t"<<wt[i]<<"\t\t"<<tat[i];
cout<<endl;
}
cout<<endl<<"Srednee vremya ojidaniya="<<awt; /*Îáùåå âðåìÿ îæèä**èÿ*/
cout<<endl<<"Srednee polnoe vremya vypolnenia="<<atat;/*Îáùåå âðåìÿ âûïîë*å*èÿ*/
cin.get();
return 0;}
 
: 22:28. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru