⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 操作系统先进先出FIFO程序并发执行演示实验程序实验报告加源码!
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FIFO
{
    public partial class Form1 : Form
    {
        int fi_i = 0;
        int fi_type1 = 0;
        int fi_i1 = 0;
        int fi_i2 = 0;
        int fi_i3 = 0;
        int fi_i4 = 0;
        Label[] a = new Label[5];
        int[] fi_ii = new int[5];
        public Form1()
        {
            InitializeComponent(); 
        }
        public void suijishu()
        {
            Random r1 = new Random();
                fi_i = r1.Next(1, 24);     
        }
        public void panduan(int a,int b,int c,int d)
        {
            if (4 * a++ < 660)
            {
                if (3 * b++ > 325)
                {
                    if (2 * c++ > 325)
                    {
                        if (1 * d++ > 325)
                        {
                            fi_type1 = 1;
                        }
                        else
                        {
                            fi_type1 = 2;
                        }
                    }
                    else
                    {
                        fi_type1 = 3;
                    }
                }
                else
                {
                    fi_type1 = 4;
       
                }
            }
            else
                if (3 * b++ < 660)
                {
                    if (2 * c++ > 325)
                    {
                        if (1 * d++ > 325)
                        {
                            fi_type1 = 5;
                        }
                        else
                        {
                            fi_type1 = 6;
                        }
                    }
                    else
                    {
                        fi_type1 = 7;
                    }
                }
                else
                    if (2 * c++ < 660)
                    {
                        if (1 * d++ > 325)
                        {
                            fi_type1 = 8;
                        }
                        else
                        {
                            fi_type1 = 9;
                        }
                    }
                    else
                    {
                        if (1 * d++ < 660)
                        {
                            fi_type1 = 10;
                        }
                        else
                        {
                            fi_type1 = 11;
                        }
                    }
        }

        public void xuanze(int A, int B, int C, int D)
        {
            switch (fi_type1)
            {
                case 1:
                    a[A].SetBounds(4 * (fi_ii[A]++), a[A].Location.Y, 40, 40);
                    break;
                case 2:
                    a[A].SetBounds(4 * (fi_ii[A]++), a[A].Location.Y, 40, 40);
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 3:
                    a[A].SetBounds(4 * (fi_ii[A]++), a[A].Location.Y, 40, 40);
                    a[C].SetBounds(2 * (fi_ii[C]++), a[C].Location.Y, 40, 40);
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 4:
                    a[A].SetBounds(4 * (fi_ii[A]++), a[A].Location.Y, 40, 40);
                    a[B].SetBounds(3 * (fi_ii[B]++), a[B].Location.Y, 40, 40);
                    a[C].SetBounds(2 * (fi_ii[C]++), a[C].Location.Y, 40, 40);
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 5:
                    a[B].SetBounds(3 * (fi_ii[B]++), a[B].Location.Y, 40, 40);
                    break;
                case 6:
                    a[B].SetBounds(3 * (fi_ii[B]++), a[B].Location.Y, 40, 40);
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 7:
                    a[B].SetBounds(3 * (fi_ii[B]++), a[B].Location.Y, 40, 40);
                    a[C].SetBounds(2 * (fi_ii[C]++), a[C].Location.Y, 40, 40);
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 8:
                    a[C].SetBounds(2 * (fi_ii[C]++), a[C].Location.Y, 40, 40);
                    break;
                case 9:
                    a[C].SetBounds(2 * (fi_ii[C]++), a[C].Location.Y, 40, 40);
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 10:
                    a[D].SetBounds(1 * (fi_ii[D]++), a[D].Location.Y, 40, 40);
                    break;
                case 11:
                    a[A].SetBounds(0, a[A].Location.Y, 40, 40);
                    a[B].SetBounds(0, a[B].Location.Y, 40, 40);
                    a[C].SetBounds(0, a[C].Location.Y, 40, 40);
                    a[D].SetBounds(0, a[D].Location.Y, 40, 40);
                    break;
            }
        }
        
       
       
        private void buttonkaishi_Click(object sender, EventArgs e)
        {
            
            chushihua();
            suijishu();
            timer1.Enabled = true;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            switch (fi_i)
            {
                case 1:
                    panduan(fi_ii[1], fi_ii[2], fi_ii[3], fi_ii[4]);
                    xuanze(1,2,3,4); break;
                case 2:
                    panduan(fi_ii[2], fi_ii[4], fi_ii[1], fi_ii[3]);
                    xuanze(2,4,1,3); break;
                case 3:
                    panduan(fi_ii[1], fi_ii[4], fi_ii[2], fi_ii[3]);
                    xuanze(1,4,2,3); break;
                case 4:
                    panduan(fi_ii[3], fi_ii[1], fi_ii[4], fi_ii[2]);
                    xuanze(3,1,4,2); break;
                case 5:
                    panduan(fi_ii[1], fi_ii[3], fi_ii[2], fi_ii[4]);
                    xuanze(1,3,2,4); break;
                case 6:
                    panduan(fi_ii[2], fi_ii[1], fi_ii[4], fi_ii[3]);
                    xuanze(2,1,4,3); break;
                case 7:
                    panduan(fi_ii[4], fi_ii[3], fi_ii[2], fi_ii[1]);
                    xuanze(4,3,2,1); break;
                case 8:
                    panduan(fi_ii[4], fi_ii[2], fi_ii[1], fi_ii[3]);
                    xuanze(4,2,1,3); break;
                case 9:
                    panduan(fi_ii[3], fi_ii[4], fi_ii[1], fi_ii[2]);
                    xuanze(3,4,1,2); break;
                case 10:
                    panduan(fi_ii[2], fi_ii[3], fi_ii[4], fi_ii[1]);
                    xuanze(2,3,4,1); break;
                case 11:
                    panduan(fi_ii[2], fi_ii[3], fi_ii[1], fi_ii[4]);
                    xuanze(2,3,1,4); break;
                case 12:
                    panduan(fi_ii[1], fi_ii[2], fi_ii[4], fi_ii[3]);
                    xuanze(1,2,4,3); break;
                case 13:
                    panduan(fi_ii[1], fi_ii[3], fi_ii[4], fi_ii[2]);
                    xuanze(1,3,4,2); break;
                case 14:
                    panduan(fi_ii[1], fi_ii[4], fi_ii[3], fi_ii[2]);
                    xuanze(1,4,3,2); break;
                case 15:
                    panduan(fi_ii[2], fi_ii[1], fi_ii[3], fi_ii[4]);
                    xuanze(2,1,3,4); break;
                case 16:
                    panduan(fi_ii[2], fi_ii[3], fi_ii[1], fi_ii[4]);
                    xuanze(2,3,1,4); break;
                case 17:
                    panduan(fi_ii[3], fi_ii[1], fi_ii[2], fi_ii[4]);
                    xuanze(3,1,2,4); break;
                case 18:
                    panduan(fi_ii[3], fi_ii[4], fi_ii[2], fi_ii[1]);
                    xuanze(3,4,2,1); break;
                case 19:
                    panduan(fi_ii[3], fi_ii[2], fi_ii[1], fi_ii[4]);
                    xuanze(3,2,1,4); break;
                case 20:
                    panduan(fi_ii[3], fi_ii[2], fi_ii[4], fi_ii[1]);
                    xuanze(3,2,4,1); break;
                case 21:
                    panduan(fi_ii[4], fi_ii[3], fi_ii[1], fi_ii[2]);
                    xuanze(4,3,1,2); break;
                case 22:
                    panduan(fi_ii[4], fi_ii[2], fi_ii[3], fi_ii[1]);
                    xuanze(4,2,3,1); break;
                case 23:
                    panduan(fi_ii[4], fi_ii[1], fi_ii[2], fi_ii[3]);
                    xuanze(4,1,2,3); break;
                case 24:
                    panduan(fi_ii[4], fi_ii[1], fi_ii[3], fi_ii[2]);
                    xuanze(4,1,3,2); break;
                    
            }
           
            timer1.Enabled = true;
        }
        public void chushihua()
        {
             fi_i = 0;
             fi_type1 = 0;
             fi_i1 = 0;
             fi_i2 = 0;
             fi_i3 = 0;
             fi_i4 = 0;
             a[1] = label1;
             a[2] = label2;
             a[3] = label3;
             a[4] = label4;
             fi_ii[1] = fi_i1;
             fi_ii[2] = fi_i2;
             fi_ii[3] = fi_i3;
             fi_ii[4] = fi_i4;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -