עבור לתוכן
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.

התכנית מחכה לקלט נוסף ומעכבת את התקדמות הריצה.

Featured Replies

פורסם

שאלה פשוטה לי אליכם:

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

התכנית נעשתה ב-CodeBlocks.

תודה.[br]פורסם בתאריך: 8.03.2010 בשעה 20:22:35


טוב נו, כמובן שפתרתי זאת על ידי הורדה של ה-\n מה-scanf. :screwy:

בכל זאת אשמח להסבר, מדוע זה קרה?

[attachment deleted by admin]

פורסם

נסה לשנות את הקוד ל:

int main ()

{

int num1,num2

printf ("Please enter two numbers: \n");

scanf("%d\n", &num1);

scanf("%d\n", &num2);

printf ("The product is:%d\n",num1*num2);

return 0;

}

האם עכשיו זה בסדר ??

פורסם
  • מחבר

שים לב שערכתי את ההודעה.

קטע התכנית שלך שקול לשלי, הבעיה נתונה ב-"\n" בפונקצית הקלט.

האם זה שגוי לשים "\n" בפונקצית הקלט?

פורסם

http://msdn.microsoft.com/en-us/library/kwwtf9ch%28VS.71%29.aspx

White-space characters: blank (' '); tab ('\t'); or newline ('\n'). A white-space character causes scanf to read, but not store, all consecutive white-space characters in the input up to the next non–white-space character. One white-space character in the format matches any number (including 0) and combination of white-space characters in the input.

כשאתה שם n\ בסוף ה-scanf, אז אחרי שהוא קורא את המספר הוא ממשיך לקרוא עד שהוא נתקל בקלט שהוא לא white-space (רווח, טאב או סוף שורה). כיוון שעדיין לא היה קלט כזה, הוא מחכה לו.

ארכיון

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

דיונים חדשים

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.