• <nav id="cwumo"><code id="cwumo"></code></nav>
  • <menu id="cwumo"><strong id="cwumo"></strong></menu>

    C++編程實例

    時間:2020-11-23 10:02:29 筆試經驗 我要投稿

    C++編程實例

      隨機分配座位,共50個學生,使學號相鄰的同學座位不能相鄰(早些時候用C#寫的,沒有用C改寫)。

      static void Main(string[] args)

      {

      int Tmp = 0, Count = 50;

      int[] Seats = new int[Count];

      bool[] Students = new bool[Count];

      System.Random RandStudent=new System.Random();

      Students[Seats[0]=RandStudent.Next(0,Count)]=true;

      for(int i = 1; i < Count; ) {

      Tmp=(int)RandStudent.Next(0,Count);

      if((!Students[Tmp])&&(Seats[i-1]-Tmp!=1) && (Seats[i-1] – Tmp) != -1) {

      Seats[i++] = Tmp;

      Students[Tmp] = true;

      }

      }

      foreach(int Student in Seats)

      System.Console.Write(Student + ” “);

      System.Console.Read();

      }

    【C++編程實例】相關文章:

    面試中編程實例12-13

    ASP編程實例大全10-16

    C++筆試實例分析12-19

    一個C/C++編程面試題12-20

    Javascript簡單實現面向對象編程繼承實例代碼11-18

    考查C++/C程序員的基本編程技能11-25

    c++筆試實例:計算s=f(f(-1.4))的值12-14

    關于C++編程中對象生命周期管理的論文06-15

    C++筆試實例:int *p=NULL和*p= NULL有什么區別12-19

    有心情的試一試,考查C++/C程序員的基本編程技能11-01

    日韩激情