«یا اللهُ یا رَبِّ یا حَیُّ یا قَیّوم یا ذَالجَلالِ وَ الاکرام اَسئَلُکَ بِاسمِکَ اَلعَظیم اَلاَعظَم اَن تَرزُقَنی رِزقاً حَلالاً طَیِّباً بِرَحمَتِکَ الواسِعَه یا اَرحَمَ الرّاحِمِین.»
برنامه ی عدد اول به زبان سیشارپ_با استفاده از نخ thread :: گیم اور _ بازیسازی با unity + مطالب متفرقه

گیم اور _ بازیسازی با unity + مطالب متفرقه

آموزش های علمی با اجازه ی خدا تقدیم به هرکس خدا بخواد

آموزش های علمی با اجازه ی خدا تقدیم به هرکس خدا بخواد

به نام خدا
--
گروه قدیم ما promakers.ir یا پرومیکرز بود که بالای هزار اموزش توش ساخته بودم به اسم sajjad3011 ولی حیف ادمین سایتش عوض کرد
حالا سوالی بود کاری بود این شمارمه

قدیمیا دلم براتون تنگ شده... فقط معرفی کنید توی پیامک یا تماس یاد بیارید.
اگه جواب ندادم شاید موقعیت نداشته باشم.
بگید توی پیام از بچه های پرومیکرز هستید.

---
سوالی بود بذارید
نظر خصوصی نذارید
پاسخش سخته
دوست داشتید شماره بذارید تو واتساپ یا ایتا یا .... گروه بزنیم.
09358077198

بایگانی
پیوندها

gameover.blog.ir



/*
** Project Name: PrimeTime
** Author: Robert Whitney <xnite@xnite.me>
** Description: Uses multi-threading to find prime numbers in generated chunks and then prints all primes to the screen.
**    Processes about 873,190 numbers/second in blocks of 10,000 using 4 worker threads.
**    Tested on Windows 8.1 x64, w/ Intel Core i7 2600 (3.40GHz) processor.
**    Max integer limited to value of Int32.MaxValue (2,147,483,647)
*/
/* Include libraries for the project */
using System;
using System.Threading;
using System.Diagnostics;
 
namespace PrimeTime
{
    class PrimeTime
    {
        static void Main(string[] args)
        {
            int i;
            int initThreadCount = Process.GetCurrentProcess().Threads.Count;
            bool num = int.TryParse(args[0], out i);
            if( i < 0 )
            {
                Console.WriteLine("Starting point must be 0 or greater!");
            }
            while ( i <= Int32.MaxValue && i >= 0 )
            {
                if( Process.GetCurrentProcess().Threads.Count-initThreadCount <= 4 )
                {
                    Thread t = new Thread(() => checkBlockForPrime(i, i + 9999));
                    t.Start();
                    if (Int32.MaxValue - 10000 <= i)
                    {
                        i = Int32.MaxValue - 10000;
                    }
                    else
                    {
                        if (i == Int32.MaxValue)
                        {
                            Console.WriteLine("I have reached the maximum value of an int.");
                            break;
                        }
                        else
                        {
                            i = i + 10000;
                        }
                    }
                }
            }
            Console.WriteLine("Cannot process numbers larger than " + Int32.MaxValue + " and will not process numbers smaller than 0");
        }
 
        public static void checkBlockForPrime(int start, int end)
        {
            int i = start;
            while( i <= end )
            {
                if (checkPrime(i) == true)
                {
                    Console.WriteLine(i);
                }
                i = i + 1;
            }
        }
        public static bool checkPrime(int num)
        {
            // Test whether the parameter is a prime number.
            if ((num & 1) == 0)
            {
                if (num == 2)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            for (int i = 3; (i * i) <= num; i += 2)
            {
                if ((num % i) == 0)
                {
                    return false;
                }
            }
            return true;
        }
    }
}
موافقین ۰ مخالفین ۰ ۹۶/۰۵/۱۷
مدیرکل

نظرات (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی