{"id":6959,"date":"2024-03-25T23:01:01","date_gmt":"2024-03-25T15:01:01","guid":{"rendered":""},"modified":"2024-03-25T23:01:01","modified_gmt":"2024-03-25T15:01:01","slug":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6","status":"publish","type":"post","link":"https:\/\/mushiming.com\/6959.html","title":{"rendered":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\n

\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6<\/h4>\n


\n \u5047\u8bbe\u67d0\u5355\u5904\u7406\u673a\u7cfb\u7edf\u91c7\u7528\u201c\u57fa\u4e8e\u52a8\u6001\u4f18\u5148\u6743\u7684\u65f6\u95f4\u7247\u8f6e\u8f6c\u201d\u8c03\u5ea6\u7b97\u6cd5\u3002\u8fdb\u7a0b\u961f\u5217\u91c7\u7528\u5355\u5411\u94fe\u8868\u7ec4\u7ec7\u8fdb\u7a0b\u63a7\u5236\u5757\u3002<\/strong>\n<\/div>\n<\/p>\n

\u8fc7\u7a0b\uff1a\u5047\u8bbe\u8fdb\u5165\u7684\u8fdb\u7a0b\u67093\u4e2a\uff0c\u8f6e\u8f6c\u65f6\u95f4\u7247\u4e3a5\uff0c\u6bcf\u7ecf\u8fc7\u4e00\u4e2a\u65f6\u95f4\u7247\u8981\u4e48\u4f18\u5148\u7ea7\u53d1\u751f\u53d8\u5316\uff08\u5728\u6211\u7684\u5b9e\u9a8c\u4e2d\u52a02\uff0c\u4e5f\u5c31\u662f\u4f18\u5148\u7ea7\u964d\u4f4e\u4e24\u4e2a\u7b49\u7ea7\uff09\uff0c\u8981\u4e48\u8be5\u8fdb\u7a0b\u7ed3\u675f\uff08\u5220\u9664\u8282\u70b9\uff09\u3002
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u8fd0\u884c\u903b\u8f91\u5982\u4e0b\uff1a
\u521d\u59cb\u5316\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u6839\u636e\u4f18\u5148\u7ea7\u6392\u5e8f\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u7b2c\u4e00\u4e2a\u65f6\u95f4\u7247\u8f6e\u8f6c\u540e\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u7b2c\u4e8c\u4e2a\u65f6\u95f4\u7247\u8f6e\u8f6c\u540e\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u7b2c\u4e09\u4e2a\u65f6\u95f4\u7247\u8f6e\u8f6c\u540e\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u7b2c\u56db\u4e2a\u65f6\u95f4\u7247\u8f6e\u8f6c\u540e\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6
\u7b2c\u4e94\u4e2a\u65f6\u95f4\u7247\u8f6e\u8f6c\u540e\u6240\u6709\u8282\u70b9\u5747\u88ab\u5220\u9664\u3002
\u4ee3\u7801\uff1a<\/strong><\/em><\/p>\n

#include<\/span> <stdio.h><\/span><\/span>\n#include<\/span> <stdlib.h><\/span><\/span>\n#include<\/span> <string.h><\/span><\/span>\n\ntypedef<\/span> struct<\/span> pcb\n{ \n   <\/span>\n    int<\/span> name;<\/span>                 \/\/\u8fdb\u7a0b\u540d<\/span>\n    int<\/span> status;<\/span>               \/\/\u8fdb\u7a0b\u72b6\u6001<\/span>\n    int<\/span> priority;<\/span>             \/\/\u8fdb\u7a0b\u4f18\u5148\u7ea7<\/span>\n    int<\/span> time;<\/span>                 \/\/\u8fdb\u7a0b\u6240\u9700\u8fd0\u884c\u65f6\u95f4<\/span>\n    struct<\/span> pcb *<\/span>next;<\/span>         \/\/\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9<\/span>\n}<\/span>pcb;<\/span>\n\nint<\/span> M;<\/span>\npcb *<\/span>creat<\/span>(<\/span>int<\/span> count,<\/span> pcb *<\/span>head)<\/span>   \/\/count\u4e3a\u8fdb\u7a0b\u6570<\/span>\n{ \n   <\/span>\n    pcb *<\/span>q,<\/span> *<\/span>p;<\/span>\n    head =<\/span> (<\/span>pcb *<\/span>)<\/span>malloc<\/span>(<\/span>sizeof<\/span>(<\/span>pcb)<\/span>)<\/span>;<\/span> \/\/\u5934\u6307\u9488<\/span>\n    p =<\/span> head;<\/span>\n    int<\/span> i =<\/span> 0<\/span>;<\/span>\n    for<\/span>(<\/span>i =<\/span> 0<\/span>;<\/span> i <<\/span> count;<\/span> i++<\/span>)<\/span>\n\t{ \n   <\/span>\n        q =<\/span> (<\/span>pcb *<\/span>)<\/span>malloc<\/span>(<\/span>sizeof<\/span>(<\/span>pcb)<\/span>)<\/span>;<\/span>\n        printf<\/span>(<\/span>\"input %d process name: \"<\/span>,<\/span> i+<\/span>1<\/span>)<\/span>;<\/span>\n        scanf<\/span>(<\/span>\"%d\"<\/span>,<\/span> &<\/span>q-><\/span>name)<\/span>;<\/span>\n        printf<\/span>(<\/span>\"input %d process priority: \"<\/span>,<\/span> i+<\/span>1<\/span>)<\/span>;<\/span>\n        scanf<\/span>(<\/span>\"%d\"<\/span>,<\/span> &<\/span>q-><\/span>priority)<\/span>;<\/span>\n        printf<\/span>(<\/span>\"input %d process time: \"<\/span>,<\/span> i+<\/span>1<\/span>)<\/span>;<\/span>\n        scanf<\/span>(<\/span>\"%d\"<\/span>,<\/span> &<\/span>q-><\/span>time)<\/span>;<\/span>\n        q-><\/span>status =<\/span> 1<\/span>;<\/span> \/\/\u9ed8\u8ba4\u8fdb\u7a0b\u4e3a\u5c31\u7eea\u6001<\/span>\n        p-><\/span>next =<\/span> q;<\/span>\n        p =<\/span> q;<\/span>\n    }<\/span>\n    p-><\/span>next =<\/span> NULL<\/span>;<\/span>\n    return<\/span> head;<\/span>\n}<\/span>\n\nvoid<\/span> Sort1<\/span>(<\/span>pcb *<\/span>head)<\/span>\n{ \n   <\/span>\n    pcb *<\/span> q,<\/span> *<\/span>p,<\/span> *<\/span>tail,<\/span> *<\/span>temp;<\/span>\n    tail =<\/span> NULL<\/span>;<\/span>\n    q =<\/span> head;<\/span>\n    while<\/span>(<\/span>(<\/span>head-><\/span>next)<\/span> !=<\/span> tail)<\/span>\n\t{ \n   <\/span>\n        p =<\/span> head-><\/span>next;<\/span>\n        q =<\/span> head;<\/span>\n        while<\/span>(<\/span>p-><\/span>next !=<\/span> tail)<\/span>\n\t\t{ \n   <\/span>\n\t        if<\/span>(<\/span>(<\/span>p-><\/span>priority)<\/span> ><\/span> (<\/span>p-><\/span>next-><\/span>priority)<\/span>)<\/span>{ \n   <\/span>\n\t            q-><\/span>next =<\/span> p-><\/span>next;<\/span>\n\t            temp =<\/span> p-><\/span>next-><\/span>next;<\/span>\n\t            p-><\/span>next-><\/span>next =<\/span> p;<\/span>\n\t            p-><\/span>next =<\/span> temp;<\/span>\n\t            p =<\/span> q-><\/span>next;<\/span>\n\t        }<\/span>\n\t        p =<\/span> p-><\/span>next;<\/span>\n\t        q =<\/span> q-><\/span>next;<\/span>\n    \t}<\/span>\n    \ttail =<\/span> p;<\/span>\n    }<\/span>\n\n}<\/span>\n\nvoid<\/span> Print<\/span>(<\/span>pcb *<\/span>head)<\/span>\n{ \n   <\/span>\n\tpcb *<\/span>ptr =<\/span> head-><\/span>next;<\/span>\n    while<\/span>(<\/span>ptr !=<\/span> NULL<\/span>)<\/span>{ \n   <\/span>\n          printf<\/span>(<\/span>\"name = %d, pro = %d, status = %d, time = %d\\n\"<\/span>,<\/span> ptr-><\/span>name,<\/span>ptr-><\/span>priority,<\/span> ptr-><\/span>status,<\/span> ptr-><\/span>time)<\/span>;<\/span>\n          ptr =<\/span> ptr-><\/span>next;<\/span>\n    }<\/span>\n}<\/span>\n\npcb *<\/span>sch<\/span>(<\/span>pcb *<\/span>head)<\/span>{ \n   <\/span>\n    pcb *<\/span> ptr =<\/span> head-><\/span>next;<\/span>\n    while<\/span>(<\/span>ptr !=<\/span> NULL<\/span>)<\/span>{ \n   <\/span> \/\/\u6709\u8fdb\u7a0b<\/span>\n        printf<\/span>(<\/span>\"name = %d, pro = %d, status = %d, time = %d\\n\"<\/span>,<\/span> ptr-><\/span>name,<\/span> ptr-><\/span>priority,<\/span> ptr-><\/span>status,<\/span> ptr-><\/span>time)<\/span>;<\/span>\n\n        ptr-><\/span>priority =<\/span> ptr-><\/span>priority +<\/span> 2<\/span>;<\/span>\n\n        ptr-><\/span>time =<\/span> ptr-><\/span>time -<\/span> M;<\/span>\n        if<\/span>(<\/span>ptr-><\/span>time ><\/span> 0<\/span>)<\/span> { \n   <\/span>\n            Sort1<\/span>(<\/span>head)<\/span>;<\/span>\n        }<\/span> else<\/span> { \n   <\/span>\n\t    ptr-><\/span>time =<\/span> 0<\/span>;<\/span>\n            ptr-><\/span>status =<\/span> 0<\/span>;<\/span>\n            head-><\/span>next =<\/span> ptr-><\/span>next;<\/span> \/\/\u8fdb\u7a0b\u7ed3\u675f\uff0c\u5220\u9664<\/span>\n        }<\/span>\n\n\tprintf<\/span>(<\/span>\"list:\\n\"<\/span>)<\/span>;<\/span>\n\tPrint<\/span>(<\/span>head)<\/span>;<\/span>\n\tprintf<\/span>(<\/span>\"\\n\\n\"<\/span>)<\/span>;<\/span>    \n\n\tptr =<\/span> head-><\/span>next;<\/span>\n    }<\/span>\n    return<\/span> head;<\/span>\n}<\/span>\n\nint<\/span> main<\/span>(<\/span>)<\/span>\n{ \n   <\/span>\n    int<\/span> num;<\/span>\n    pcb *<\/span>head;<\/span>\n    printf<\/span>(<\/span>\"please enter the size of the time slice:\"<\/span>)<\/span>;<\/span>\n    scanf<\/span>(<\/span>\"%d\"<\/span>,<\/span> &<\/span>M)<\/span>;<\/span>\n    printf<\/span>(<\/span>\"Number of input processes:\"<\/span>)<\/span>;<\/span>\n    scanf<\/span>(<\/span>\"%d\"<\/span>,<\/span>&<\/span>num)<\/span>;<\/span>\n\n    head =<\/span> creat<\/span>(<\/span>num,<\/span> head)<\/span>;<\/span>\n    printf<\/span>(<\/span>\"\\n\"<\/span>)<\/span>;<\/span>\n\tPrint<\/span>(<\/span>head)<\/span>;<\/span>\n\n    printf<\/span>(<\/span>\"\\n\\nstart:\\n\"<\/span>)<\/span>;<\/span>\n    Sort1<\/span>(<\/span>head)<\/span>;<\/span>\n    sch<\/span>(<\/span>head)<\/span>;<\/span>\n    return<\/span> 0<\/span>;<\/span>\n}<\/span>\n<\/code><\/pre>\n

\u7ed3\u679c\uff1a
\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6<\/p>\n","protected":false},"excerpt":{"rendered":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c\u4e4b\u5355\u5904\u7406\u673a\u7cfb\u7edf\u7684\u8fdb\u7a0b\u8c03\u5ea6\u5047\u8bbe\u67d0\u5355\u5904\u7406\u673a\u7cfb\u7edf\u91c7\u7528\u201c\u57fa\u4e8e\u52a8\u6001\u4f18\u5148\u6743\u7684\u65f6\u95f4\u7247...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6959"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=6959"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6959\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=6959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=6959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=6959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}