,   CyberForum.ru

Round Robin ( ) - C++


C++ - http://www.cyberforum.ru/cpp-beginners/thread738151.html
- #include<stdio.h> #include<math.h> #include<stdlib.h> using namespace std; int main () { int i,x1=-2,x2=2; float f,x,dx=0.01; x=x1; printf("---------------------------\n");
C++ . , . . #include "stdafx.h" #include <clocale> #include <ctime> #include <cstdlib> #include <cmath> #include <iostream> using namespace std; http://www.cyberforum.ru/cpp-beginners/thread738139.html
) .) C++
, std::string HexFunction(char * input, char * output) { const unsigned long long int constant = 16777215; unsigned int numOfDiBytes = 0; int numOfHexes; for(int i = 0; i < constant; i++) { numOfHexes = 0;
C++
)) ( + +). , . ))
C++ http://www.cyberforum.ru/cpp-beginners/thread738115.html
!) ! ) class ARRAY{ int size; double **m; public: ARRAY(int s=0):size(s){ m=new double* ; for(int i=0;i<size;i++) m=new double;}
C++ . . . time.txt : 12:00 14:00 14:10 15:40 15:45 20:00 20:10 23:00 : .

Rauan
0 / 0 / 0
: 05.12.2013
: 68
02.02.2014, 16:13     Round Robin ( )
. :

32
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;}
1
. "". :-)
 
: 06:59. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru