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

עזרה בשאלה על פונקציה וסכום 2 משתנים (c++)

Featured Replies

פורסם

כתבו פונקציה שמקבלת מספר שלם k וקולטת סדרת מספרים שלמים שמסתיימת בזקיף 1-. הפונקציה תחזיר 1 אם קיים בסדרה זוג מספרים שסכומם גדול מ-k ;אחרת, הפונקציה תחזיר 0. ניתן להניח כי יש בסדרה לפחות 2 מספרים. על הפונקציה לעצור כאשר כבר נקלטו שני מספרים שסכומם גדול מ-k. לדוגמא: עבור 18=k והסדרה הבאה )משמאל לימין( : 3, 12, 5, 10, 5, 6, 2, -1 הפונקציה תעצור אחרי שנקלט המספר 10( כי 18>10+12 )ותחזיר 1 . עבור 25=k ואותה סדרה הפונקציה תעצור אחרי שנקלט 1 -ותחזיר 0 ,כי לא קיים זוג מספרים שסכומם גדול מ-25.

 

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

 

#include<stdio.h>

int mycouple(int k) {
    int num, t1, t2;
    while (num != -1)
    {
        printf("enter numbers:");
        scanf("%d", &t1);
        scanf("%d", &t2);

        if ((t1 + t2)>k)
            return 1;

        else
            return 0;

    }

}

void main() {
    int num, t1, t2;
    int k;
    int x;
    printf("enter numbers:");
    scanf("%d", &t1);
    scanf("%d", &t2);
    x = mycopule(k);
    printf("the number is %d", x);


}
 

נערך על-ידי Aviv Raphael

ארכיון

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

דיונים חדשים

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.