Exemple #1
0
        static void Main(Math[] args)
        {
            Console.WriteLine("What would you like to multiply by 50 today?");
            int32 num1    = Console.ReadLine();
            int32 product = num11 * 50;

            Console.WriteLine(product);
        }
Exemple #2
0
        object CreateNewCanvas(int32 sizeX, int32 sizeY)           //Создаём холст указанного размера, отрисовываем.
        {
            object Canvas = new System.Drawing.Bitmap(sizeX, sizeY);



            return(Canvas);
        }
Exemple #3
0
        // Overrides the ConvertFrom method of TypeConverter.
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                int32 result = int.Parse((string)value);
                return(result);
            }

            return(base.ConvertFrom(context, culture, value));
        }
 static void Main(string[] args)
 {
     demo obj = new demo();
     string uname, pass;
     boolean successful = false;
     int32 tries = 5;
     Console.ForegroundColor = ConsoleColor.Green;
 label1:
     Do 
     {
     Console.Clear();
     Console.WriteLine("Enter username");
     uname = Console.ReadLine();
     Console.WriteLine("Enter Password");
     pass = Console.ReadLine();
     obj.setName(uname);
     obj.setPass(pass);
     if (obj.getName() == "niit")
     {
         if (obj.getPass() == "1234")
         {
             Console.WriteLine("welcome");
             successful = true;
         }
     }
     if (!successful)
     {
         tries--;
         Console.Clear();
         Console.WriteLine("Invalid");
         if (tries > 1)
         { 
            Console.WriteLine("Have " + tries + " attempts left");
         }
         ElseIf (tries == 1)
         {
            Console.WriteLine("Have only one more attempt left");
         }
         Else
         {
            Console.WriteLine("Maximum number of tries exceed");
            Console.WriteLine("Goodbye");
         }
     }
     } While(!successful && Tries > 0);
 }
 public Material()
 {
     dung        = int3232.MaxValue;
     soil        = int3232.MaxValue;
     rocks       = int3232.MaxValue;
     water       = int3232.MaxValue;
     seeds       = int3232.MaxValue;
     animals     = int3232.MaxValue;
     minerals    = int3232.MaxValue;
     elements    = int3232.MaxValue;
     sand        = int3232.MaxValue;
     food        = int3232.MaxValue;
     wood        = int3232.MaxValue;
     granite     = int3232.MaxValue;
     saltwater   = int3232.MaxValue;
     freshwater  = int3232.MaxValue;
     electricity = int3232.MaxValue;
 }
        static void toMatrix(int32[] arr, int size)
        {
            for (int i = 0; i < arr.Length / size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    System.Console.Write(arr[i * size + j]);
                    if (j > 0 && (j + 1) % cellDataRepresentationLength == 0)
                    {
                        System.Console.Write("|");
                    }

                    //if ((j) % magicConst == 0)
                    //{
                    //    System.Console.Write(arr[i * size + j]);
                    //    System.Console.Write("|");
                    //}
                }
                System.Console.WriteLine();
            }
        }
Exemple #7
0
        // CCD via the secant method.
        /// <summary>
        /// Compute the time when two shapes begin to touch or touch at a closer distance.
        /// TOI considers the shape radii. It attempts to have the radii overlap by the tolerance.
        /// Iterations terminate with the overlap is within 0.5 * tolerance. The tolerance should be
        /// smaller than sum of the shape radii.
        /// Warning the sweeps must have the same time interval.
        /// </summary>
        /// <returns>
        /// The fraction between [0,1] in which the shapes first touch.
        /// fraction=0 means the shapes begin touching/overlapped, and fraction=1 means the shapes don't touch.
        /// </returns>
        public static float TimeOfImpact(TOIInput input, Shape shapeA, Shape shapeB)
        {
            Sweep sweepA = input.SweepA;
            Sweep sweepB = input.SweepB;

            Box2DNetDebug.Assert(sweepA.T0 == sweepB.T0);
            Box2DNetDebug.Assert(1.0f - sweepA.T0 > Common.Settings.FLT_EPSILON);

            float radius    = shapeA._radius + shapeB._radius;
            float tolerance = input.Tolerance;

            float alpha = 0.0f;

            const int k_maxIterations = 1000;                   // TODO_ERIN b2Settings
            int       iter            = 0;
            float     target          = 0.0f;

            // Prepare input for distance query.
            SimplexCache cache = new SimplexCache {
                Count = 0
            };
            DistanceInput distanceInput;

            distanceInput.UseRadii = false;

            for (; ;)
            {
                XForm xfA, xfB;
                sweepA.GetTransform(out xfA, alpha);
                sweepB.GetTransform(out xfB, alpha);

                // Get the distance between shapes.
                distanceInput.TransformA = xfA;
                distanceInput.TransformB = xfB;
                DistanceOutput distanceOutput;
                Distance(out distanceOutput, ref cache, ref distanceInput, shapeA, shapeB);

                if (distanceOutput.Distance <= 0.0f)
                {
                    alpha = 1.0f;
                    break;
                }

                SeparationFunction fcn = new SeparationFunction();
                unsafe
                {
                    fcn.Initialize(&cache, shapeA, xfA, shapeB, xfB);
                }

                float separation = fcn.Evaluate(xfA, xfB);
                if (separation <= 0.0f)
                {
                    alpha = 1.0f;
                    break;
                }

                if (iter == 0)
                {
                    // Compute a reasonable target distance to give some breathing room
                    // for conservative advancement. We take advantage of the shape radii
                    // to create additional clearance.
                    target = separation > radius?Common.Math.Max(radius - tolerance, 0.75f *radius) : Common.Math.Max(separation - tolerance, 0.02f * radius);
                }

                if (separation - target < 0.5f * tolerance)
                {
                    if (iter == 0)
                    {
                        alpha = 1.0f;
                        break;
                    }

                    break;
                }

#if _FALSE
                // Dump the curve seen by the root finder
                {
                    const int32 N  = 100;
                    float32     dx = 1.0f / N;
                    float32     xs[N + 1];
 public Person(Action work, @string name, int32 age)
 {
     this.work = work;
     this.name = name;
     this.age  = age;
 }
 public Person(@string name, int32 age)
 {
     this.name = name;
     this.age  = age;
 }
Exemple #10
0
 private void SetInt(ref int32 z)
 {
     z = 42;
 }
IL_0005: call void [System.Console] System.Console::WriteLine(int32)
        IL_000a : ret
Exemple #12
0
        static void Do()
        {
            var c = 4;
            var inArr = new int32 [c];
            for (int _i = 0; _i < c; _i++) { inArr[_i] = 2; }
            inArr[c-2] = 1;
            int32 size = inArr.Length;

            var rules = new Rule[] {new Rule(1,2,3,0,0),new Rule(2,3,2,0,0),new Rule(2,1,0,0,0),new Rule(3,2,0,0,0)};

            var nTermRules = (from rule in rules where rule.c > 0 select rule).ToArray();

            int32 nTerms = 3;

            string platformName = "*";

            Cl.DeviceType deviceType = Cl.DeviceType.Default;

            ComputeProvider provider;
            try
            {
                provider = ComputeProvider.Create(platformName, deviceType);
            }
            catch (PlatformNotSupportedException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            var commandQueue = new CommandQueue(provider, provider.Devices.First());            

            var bArr = new int32[size * size * nTerms * cellDataRepresentationLength];
            var rulesArr = new uint32[nTermRules.Length * ruleRepresentationLength];

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < rules.Length; j++)
                {
                    if (inArr[i] == (rules[j]).b && (rules[j]).c == 0)
                    {
                        var _base = (i * nTerms  + (int)(rules[j].a - 1)) * cellDataRepresentationLength;
                        bArr[_base] = rules[j].a;
                        //bArr[_base + 1] = 0;
                        //bArr[_base + 2] = (rules[j].lblNum == 0 ? 1 : 0);
                        ///bArr[_base + 3] = rules[j].lblNum;
                        //bArr[_base + 4] = rules[j].lblWeight;
                    }
                }
            }

            for (int i = 0; i < nTermRules.Length; i++)
            {
                var _base =  i * ruleRepresentationLength;
                rulesArr[_base] = (uint32)(uint)(nTermRules[i].a << 16 | nTermRules[i].b);
                rulesArr[_base + 1] = (uint32)(uint)nTermRules[i].c;
                //rulesArr[_base + 3] = rules[i].lblNum;
                //rulesArr[_base + 4] = rules[i].lblWeight;
            }            

            var buffer = new Buffer<int32>(provider, Operations.ReadWrite, Memory.Device, bArr);
            var rulesBuffer = new Buffer<uint32>(provider, Operations.ReadOnly, Memory.Device, rulesArr);

            int32 rLength = nTermRules.Length;

            var processRow = provider.Compile<_1D, int32, Buffer<int32>, Buffer<uint32>>(
                (range, l, a, _rules) =>
                    from r in range
                    let i = r.GlobalID0
                    let nT = nTerms
                    let _base = nT * size
                    let res_id_base = (l * _base) + i * nT
                    let iter = provider.Loop(0, l, kIdx=>
                        from k in kIdx
                        let left_base_idx = (k * _base) + i * nTerms
                        let right_base_idx = ((l - k - 1) * _base) + (k + i + 1) * nTerms
                        let iter2 = provider.Loop(0, rLength, rIdxs =>
                            from rId in rIdxs
                            let rule_base = rId * ruleRepresentationLength
                            let rule_a_b = _rules[rule_base]
                            let rule_a = (int)((rule_a_b >> 16) & 0xFFFF)
                            let rule_b = (int)(rule_a_b & 0xFFFF)
                            let rule_c = (int)(_rules[rule_base + 1] | 0)
                            let res_id = res_id_base + ((int)(uint)rule_a - 1)
                            select new[]{(rule_c != 0
                                          & rule_c == a[right_base_idx + (rule_c - 1)] 
                                          & rule_b == a[left_base_idx + (rule_b - 1)])
                                          ? a[res_id] <= rule_a
                                          : ((Brahma.Set<int32>)null)})
                        select (Brahma.Set<int32>[])null)
                    select (Brahma.Set<int32>[])null);

            for (int l = 1; l < size; l++)
            {
                commandQueue.Add(processRow.Run(new _1D(size - l), l, buffer, rulesBuffer)).Finish();
            }
            
            commandQueue.Add(buffer.Read(0, size * size * nTerms * cellDataRepresentationLength, bArr)).Finish();
            toMatrix(bArr, (int)(size * nTerms * cellDataRepresentationLength));
            buffer.Dispose();

            commandQueue.Dispose();
            provider.Dispose();
        }
Exemple #13
0
 public override bool WaitOne(int32 timeout)
 {
     return(InternalEvent.WaitOne());
 }
        static void Do()
        {
            var c     = 4;
            var inArr = new int32 [c];

            for (int _i = 0; _i < c; _i++)
            {
                inArr[_i] = 2;
            }
            inArr[c - 2] = 1;
            int32 size = inArr.Length;

            var rules = new Rule[] { new Rule(1, 2, 3, 0, 0), new Rule(2, 3, 2, 0, 0), new Rule(2, 1, 0, 0, 0), new Rule(3, 2, 0, 0, 0) };

            var nTermRules = (from rule in rules where rule.c > 0 select rule).ToArray();

            int32 nTerms = 3;

            string platformName = "*";

            Cl.DeviceType deviceType = Cl.DeviceType.Default;

            ComputeProvider provider;

            try
            {
                provider = ComputeProvider.Create(platformName, deviceType);
            }
            catch (PlatformNotSupportedException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            var commandQueue = new CommandQueue(provider, provider.Devices.First());

            var bArr     = new int32[size * size * nTerms * cellDataRepresentationLength];
            var rulesArr = new uint32[nTermRules.Length * ruleRepresentationLength];

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < rules.Length; j++)
                {
                    if (inArr[i] == (rules[j]).b && (rules[j]).c == 0)
                    {
                        var _base = (i * nTerms + (int)(rules[j].a - 1)) * cellDataRepresentationLength;
                        bArr[_base] = rules[j].a;
                        //bArr[_base + 1] = 0;
                        //bArr[_base + 2] = (rules[j].lblNum == 0 ? 1 : 0);
                        ///bArr[_base + 3] = rules[j].lblNum;
                        //bArr[_base + 4] = rules[j].lblWeight;
                    }
                }
            }

            for (int i = 0; i < nTermRules.Length; i++)
            {
                var _base = i * ruleRepresentationLength;
                rulesArr[_base]     = (uint32)(uint)(nTermRules[i].a << 16 | nTermRules[i].b);
                rulesArr[_base + 1] = (uint32)(uint)nTermRules[i].c;
                //rulesArr[_base + 3] = rules[i].lblNum;
                //rulesArr[_base + 4] = rules[i].lblWeight;
            }

            var buffer      = new Buffer <int32>(provider, Operations.ReadWrite, Memory.Device, bArr);
            var rulesBuffer = new Buffer <uint32>(provider, Operations.ReadOnly, Memory.Device, rulesArr);

            int32 rLength = nTermRules.Length;

            var processRow = provider.Compile <_1D, int32, Buffer <int32>, Buffer <uint32> >(
                (range, l, a, _rules) =>
                from r in range
                let i                                                       = r.GlobalID0
                                             let nT                         = nTerms
                                                                  let _base = nT * size
                                                                              let res_id_base                       = (l * _base) + i * nT
                                                                                                           let iter = provider.Loop(0, l, kIdx =>
                                                                                                                                    from k in kIdx
                                                                                                                                    let left_base_idx = (k * _base) + i * nTerms
                                                                                                                                                        let right_base_idx                         = ((l - k - 1) * _base) + (k + i + 1) * nTerms
                                                                                                                                                                                         let iter2 = provider.Loop(0, rLength, rIdxs =>
                                                                                                                                                                                                                   from rId in rIdxs
                                                                                                                                                                                                                   let rule_base = rId * ruleRepresentationLength
                                                                                                                                                                                                                                   let rule_a_b = _rules[rule_base]
                                                                                                                                                                                                                                                  let rule_a = (int)((rule_a_b >> 16) & 0xFFFF)
                                                                                                                                                                                                                                                               let rule_b = (int)(rule_a_b & 0xFFFF)
                                                                                                                                                                                                                                                                            let rule_c = (int)(_rules[rule_base + 1] | 0)
                                                                                                                                                                                                                                                                                         let res_id = res_id_base + ((int)(uint)rule_a - 1)
                                                                                                                                                                                                                                                                                                      select new[] { (rule_c != 0
                                                                                                                                                                                                                                                                                                                      & rule_c == a[right_base_idx + (rule_c - 1)]
                                                                                                                                                                                                                                                                                                                      & rule_b == a[left_base_idx + (rule_b - 1)])
                                          ? a[res_id] <= rule_a
                                          : ((Brahma.Set <int32>)null) })
                                                                                                                                                                                                     select(Brahma.Set <int32>[]) null)
                                                                                                                      select(Brahma.Set <int32>[]) null);

            for (int l = 1; l < size; l++)
            {
                commandQueue.Add(processRow.Run(new _1D(size - l), l, buffer, rulesBuffer)).Finish();
            }

            commandQueue.Add(buffer.Read(0, size * size * nTerms * cellDataRepresentationLength, bArr)).Finish();
            toMatrix(bArr, (int)(size * nTerms * cellDataRepresentationLength));
            buffer.Dispose();

            commandQueue.Dispose();
            provider.Dispose();
        }
    public static ResultStatus Success(int32 id, ErrorCode errorCode, List <string> userMessages)
    {
        ResultStatus resultStatus = new ResultStatus(id, errorCode, userMessages);

        return(resultStatus);
    }