Esempio n. 1
0
        static void FindSum(int[] arr, int K)
        {
            int n = arr.Length;
            aux[] Aux = new aux[n * (n - 1) / 2];

            int ndx = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    Aux[ndx++] = new aux(arr[i], arr[j]);
                }
            }

            //Aux = Aux.OrderBy(o => o.sum).ToArray(); //We can use sorting if we are not allowed to use extra space like dictionary, in which case sort the Aux array and use two pointers i = 0, j = aux.Length
            //and then increment/decrement i, j according to the sum
            Dictionary<int, aux> dict =new Dictionary<int,aux>();

            foreach (aux pairSum in Aux)
            {
                if (dict.ContainsKey(K - pairSum.sum))
                {
                    Console.WriteLine("Found four elements: {0}, {1}, {2}, {3}", pairSum.a, pairSum.b, dict[K - pairSum.sum].a, dict[K - pairSum.sum].b);
                    break;
                }
                if(!dict.ContainsKey(pairSum.sum))
                    dict.Add(pairSum.sum, pairSum);
            }
        }
 public IActionResult Save(int userid, string username, string userpass, int select_rol)
 {
     using (var r = new RolContext()){
         var nuevoUsuario = new user()
         {
             idUsuario         = userid,
             nombreUsuario     = username,
             contraseñaUsuario = userpass
         };
         var userAndRol = new aux()
         {
             idUsuario = userid,
             idRol     = select_rol
         };
         var usuarios = r.usuarios.Add(nuevoUsuario);
         var userRol  = r.aux.Add(userAndRol);
         r.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 初期化
        /// </summary>
        /// <param name="vVoiceId"></param>
        /// <param name="vVoiceName"></param>
        /// <param name="vVoiceId2"></param>
        /// <param name="vsTrackId"></param>
        /// <param name="auxContent"></param>
        public void Initialize(string vVoiceId = "", string vVoiceName = "", string vVoiceId2 = "", string vsTrackId = "", string auxContent = "")
        {
            vender  = new XmlDocument().CreateCDataSection("Yamaha corporation");
            version = new XmlDocument().CreateCDataSection("3.0.0.11");

            vVoiceTable _vVoiceTable = new vVoiceTable();

            mVVoiceTable = _vVoiceTable;

            mixer _mixer = new mixer();

            mMixer = _mixer;

            masterTrack _masterTrack = new masterTrack();

            mMasterTrack = _masterTrack;

            List <vsTrack> _vsTrack = new List <vsTrack>();

            mVsTrack = _vsTrack;

            monoTrack _monoTrack = new monoTrack();

            mMonoTrack = _monoTrack;

            stTrack _stTrack = new stTrack();

            mStTrack = _stTrack;

            aux _aux = new aux();

            mAux = _aux;

            //  情報のセット
            mVVoiceTable.vVoice.SetInfo(vVoiceId, vVoiceName, vVoiceId2);
            mVsTrackId = vsTrackId;
            mAux.SetInfo(auxContent);
        }