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

פורסם

אהלן, אני מחפש איך לקרוא רשימה שמכניס המשתמש, רק שהרשימה נכנסת בצורה של 12,3,4,5,6 כלומר מופרדת בפסיקים.

אני אמור לסכום את כל המספרים.


public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int nums[] = new int[100];
Byte delim = ',';
int i=0;
int sumTotal=0;

while(scan.nextByte() != 'x') {
if (!(scan.hasNextByte(delim))) {
nums[i] = scan.nextInt();
sumTotal += nums[i];
i++;
}
}
System.out.println(sumTotal);
}

זה מה שניסיתי לעשות אבל לא נראה לי שזה טוב :

  • 3 חודשים מאוחר יותר...
פורסם

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

פורסם

אם מותר לך להשתמש בsplitזה יעשה לך את רוב העבודה.

ארכיון

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

דיונים חדשים

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.