עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

זקוק להכוונה בתרגיל ב-C#

Featured Replies

פורסם

משהו פה מוזר. נסה לסגור את הפרוייקט, לפתוח מחדש ולקמפל.

  • תגובות 51
  • צפיות 8.5k
  • נוצר
  • תגובה אחרונה
פורסם
  • מחבר

באמת מוזר עכשיו הכל עובד פיקס, אני אסתכל את זה ואנסה ללמוד ממה שעשית פה

המון המון המון תודה לך.

פורסם

נראה שכבר פתרו לך, אבל בכל זאת...


using System.Collections.Generic;
using System.Linq;
using System.Text;

using System;
namespace T206
{
class Program
{
static void Main(string[] args)
{
//define prime number array
int[] primeArray = new int[30];

int idx = 0; int primeSuspect = 2; bool flagD = false;

//while array isn't full - we haven't yet collected 30 primes!
while (idx < primeArray.Length)
{
// check if number is devisalbe (ie not prime), if true it raise a flag
for (int i = 2; i < primeSuspect; i++)
{
//no reminder ie devisable
if (primeSuspect % i == 0)
{
flagD = true;
break;
}
}

// if flage wasn't raise it means it's prime! and the number is put into the array.
if (!flagD)
{
primeArray[idx] = primeSuspect;
idx++;
}

//next number to check & reset flag
primeSuspect++; flagD = false;
}

// print array of prime numbers
for (int i = 0; i < primeArray.Length; i++)
Console.Write (" " + primeArray[i]);
Console.ReadLine();

}
}
}
using System;

פורסם

אם היית קורא את הת'רד היית רואה ש:

א. כבר כתבתי לו את הפתרון.

ב. הוא לא אמור להשתמש ב-bool (אלוהים יודע למה..).

ג. הוא אמור להשתמש במערך כדי לבדוק אם המספר ראשוני, לא רק כדי להחזיק את כל המספרים הראשוניים שנמצאו עד כה.

פורסם

לא יודע... קראתי רק את הפוסט הראשון והאחרון, וזה מה שהבנתי שהתרגיל שלו מבקש.

אדיוס.

פורסם

האם שמגדרים (לא למדתי C#) משתנה bool מתכוונים לגדל שיכול להיות או TRUE או FALSE?

פורסם

כן

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.