【問(wèn)題描述】設(shè)計(jì)一個(gè)結(jié)構(gòu)體類型,描述進(jìn)程的結(jié)構(gòu),如圖1所示。然后定義一個(gè)結(jié)構(gòu)體數(shù)組存儲(chǔ)如圖2所示的4個(gè)進(jìn)程。初始時(shí)進(jìn)程的狀態(tài)都是就緒狀態(tài)即pState=1,從優(yōu)先級(jí)最高的進(jìn)程開(kāi)始執(zhí)行,將執(zhí)行的進(jìn)程狀態(tài)pState由就緒狀態(tài)改為執(zhí)行狀態(tài)即pState=2,并輸出當(dāng)前進(jìn)程信息(包括進(jìn)程的每一個(gè)屬性的信息),然后該進(jìn)程pCPU--,直到為0,將該進(jìn)程狀態(tài)改為pState=3,表示進(jìn)程執(zhí)行完畢。輸出當(dāng)前進(jìn)程信息(包括進(jìn)程的每一個(gè)屬性的信息)。接下來(lái)執(zhí)行剩余就緒狀態(tài)進(jìn)程中優(yōu)先級(jí)最高的進(jìn)程,直到?jīng)]有就緒狀態(tài)進(jìn)程為止。
成都創(chuàng)新互聯(lián)公司,專注為中小企業(yè)提供官網(wǎng)建設(shè)、營(yíng)銷型網(wǎng)站制作、響應(yīng)式網(wǎng)站設(shè)計(jì)、展示型網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì)等服務(wù),幫助中小企業(yè)通過(guò)網(wǎng)站體現(xiàn)價(jià)值、有效益。幫助企業(yè)快速建站、解決網(wǎng)站建設(shè)與網(wǎng)站營(yíng)銷推廣問(wèn)題。【樣例輸入】沒(méi)有輸入,以上信息在程序中直接賦值。
【樣例輸出】
1 :chrome.exe? 101? 10 2? 2? google chrome
2 :chrome.exe? 101? 10 2? 1? google chrome
3 :chrome.exe? 101? 10 2? 0? google chrome
3 :chrome.exe? 101? 10 3? 0? google chrome
4 :360.exe? ? ?102? 7? 2? 0? 360 safe protect
4 :360.exe? ? ?102? 7? 3? 0? 360 safe protect
5 :QQ.exe? ? ? 103? 5? 2? 3? tencet QQ
6 :QQ.exe? ? ? 103? 5? 2? 2? tencet QQ
7 :QQ.exe? ? ? 103? 5? 2? 1? tencet QQ
8 :QQ.exe? ? ? 103? 5? 2? 0? tencet QQ
8 :QQ.exe? ? ? 103? 5? 3? 0? tencet QQ
9 :CPPIDE.exe? 104? 3? 2? 1? CFree 5.0
10:CPPIDE.exe? 104? 3? 2? 0? CFree 5.0
10:CPPIDE.exe? 104? 3? 3? 0? CFree 5.0
#includeusing namespace std;
struct process
{
string pname;
int pid;
int ppriority;
int pstate;
int pcpu;
string descripition;
};
int main()
{
int count=0;
process a[4]={{"chrome.exe",101,10,2,2,"google chrome"},{"360.exe",102,7,2,0,"360 safe protect"},{"QQ.exe",103,5,2,3,"tencet QQ"},{"CPPIDE.exe",104,3,2,1,"CFree 5.0"}};
for(int i=0;i<4;i++)
{
for(int j=a[i].pcpu;j>=0;j--)
{
count++;
cout<【問(wèn)題描述】設(shè)計(jì)一個(gè)結(jié)構(gòu)體類型,描述進(jìn)程的結(jié)構(gòu),如圖1所示。然后定義一個(gè)結(jié)構(gòu)體數(shù)組或鏈表存儲(chǔ)如圖2所示的4個(gè)進(jìn)程。初始時(shí)進(jìn)程的狀態(tài)都是就緒狀態(tài)即pState=1,從優(yōu)先級(jí)最高的進(jìn)程開(kāi)始執(zhí)行,將執(zhí)行的進(jìn)程狀態(tài)pState由就緒狀態(tài)改為執(zhí)行狀態(tài)即pState=2。然后不斷循環(huán),每循環(huán)一次,就緒狀態(tài)的進(jìn)程優(yōu)先級(jí)增加1,其余不變;執(zhí)行狀態(tài)的進(jìn)程優(yōu)先級(jí)減3且其pCPU減1;當(dāng)pCPU為0時(shí),該進(jìn)程執(zhí)行完畢,其進(jìn)程狀態(tài)修改為停止即pState=3,其余不再變化。直到所有進(jìn)程pCPU都為0,則循環(huán)結(jié)束。
【樣例輸入】沒(méi)有輸入,以上信息在程序中直接賦值。
【樣例輸出】
1?:360.exe?????102??8??1??1??360?safe?protect
1?:QQ.exe??????103??6??1??4??tencet?QQ
1?:CPPIDE.exe??104??4??1??2??CFree?5.0
2?:chrome.exe??101??8??1??2??google?chrome
2?:360.exe?????102??5??2??0??360?safe?protect
2?:QQ.exe??????103??7??1??4??tencet?QQ
2?:CPPIDE.exe??104??5??1??2??CFree?5.0
3?:chrome.exe??101??5??2??1??google?chrome
3?:360.exe?????102??5??3??0??360?safe?protect
3?:QQ.exe??????103??8??1??4??tencet?QQ
3?:CPPIDE.exe??104??6??1??2??CFree?5.0
4?:chrome.exe??101??6??1??1??google?chrome
4?:360.exe?????102??5??3??0??360?safe?protect
4?:QQ.exe??????103??5??2??3??tencet?QQ
4?:CPPIDE.exe??104??7??1??2??CFree?5.0
5?:chrome.exe??101??7??1??1??google?chrome
5?:360.exe?????102??5??3??0??360?safe?protect
5?:QQ.exe??????103??6??1??3??tencet?QQ
5?:CPPIDE.exe??104??4??2??1??CFree?5.0
6?:chrome.exe??101??4??2??0??google?chrome
6?:360.exe?????102??5??3??0??360?safe?protect
6?:QQ.exe??????103??7??1??3??tencet?QQ
6?:CPPIDE.exe??104??5??1??1??CFree?5.0
7?:chrome.exe??101??4??3??0??google?chrome
7?:360.exe?????102??5??3??0??360?safe?protect
7?:QQ.exe??????103??4??2??2??tencet?QQ
7?:CPPIDE.exe??104??6??1??1??CFree?5.0
8?:chrome.exe??101??4??3??0??google?chrome
8?:360.exe?????102??5??3??0??360?safe?protect
8?:QQ.exe??????103??5??1??2??tencet?QQ
8?:CPPIDE.exe??104??3??2??0??CFree?5.0
9?:chrome.exe??101??4??3??0??google?chrome
9?:360.exe?????102??5??3??0??360?safe?protect
9?:QQ.exe??????103??2??2??1??tencet?QQ
9?:CPPIDE.exe??104??3??3??0??CFree?5.0
10:chrome.exe??101??4??3??0??google?chrome
10:360.exe?????102??5??3??0??360?safe?protect
10:QQ.exe??????103??-1?2??0??tencet?QQ
10:CPPIDE.exe??104??3??3??0??CFree?5.0
#includeusing namespace std;
struct process
{
string pname;
int pid;
int ppriority;
int pstate;
int pcpu;
string descripition;
};
int main()
{
int count=0;
process a[4]={{"chrome.exe",101,10,1,3,"google chrome"},{"360.exe",102,7,1,1,"360 safe protect"},{"QQ.exe",103,5,1,4,"tencet QQ"},{"CPPIDE.exe",104,3,1,2,"CFree 5.0"}};
while(1)
{
int max=0;
for(int j=0;j<4;j++)
{
if(a[0].pcpu==0&&a[1].pcpu==0&&a[2].pcpu==1&&a[3].pcpu==0)
{
max=2;
}
else
{
if(a[j].pcpu!=0)
{
if(a[max].ppriority
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧
文章標(biāo)題:C++程序設(shè)計(jì)實(shí)驗(yàn)5-創(chuàng)新互聯(lián)
文章路徑:http://weahome.cn/article/ehhsc.html