[Arabic] Implement Functions With C++ #11 - Trim String

Поділитися
Вставка
  • Опубліковано 26 вер 2024
  • Paid Courses
    www.elzero.cou...
    Trim String
    elzero.org/imp...
    The Implement Functions Playlist
    • Implement Functions Wi...
    Fundamentals of Programming With C++
    • Fundamentals Of Progra...
    Join Premium Members
    elzero.org/join/
    Telegram Channel For The Course:
    t.me/ElzeroCPl...

КОМЕНТАРІ • 30

  • @ElzeroWebSchool
    @ElzeroWebSchool  4 місяці тому +21

    لازم تتعلم ازاي تختصر الحل لو ينفع يختصر وتعمل حلك الخاص
    علشان تعرف انت بتتطور ولالا وبتتعلم حاجة جديدة ولالا

    • @YoussefAbdelmnem
      @YoussefAbdelmnem День тому

      حل حضرتك ممتاز الله اكبر افكار رائعه

  • @Cheriff24
    @Cheriff24 4 місяці тому +3

    ولا ليا ف البرمجة ولا اي من مشتقاتها واما ف مجال طبي اصلا شوفت بودكاستس ليك مع ابو زيد و د. ايهاب بعدها رحت لبلاي ليست رحلتي مع الحياة انت مش هتتخيل السلسلة دي غيرت طريقة تفكير ازاي و علمتني الصبر علي الظروف و الابتلاء وانه رزقك مكتوب وانت بس تسعي
    اتمني يا بشمهندس تثبت فيديو لو حتي ف الشهر عن نصائح عموما ف الحياة او قناة منفصلة
    وبارك الله فيك ❤

    • @HmoudSeng
      @HmoudSeng 4 місяці тому

      عنده قناة منفصلة بينزل عليها مواضيع مختلفة Elzero tube

  • @MedaAcademy
    @MedaAcademy 4 місяці тому +1

    ربنا يبارك في حضرتك يا هندسه ✨❤️

  • @عَبدُالرَّحْمَن-د8م8ل

    جزاك الله خيرا

  • @kintag4459
    @kintag4459 4 місяці тому

    جزاك الله عنا خير جزاء استاذ اسامه

  • @famreno5132
    @famreno5132 4 місяці тому

    بارك الله فيك ❤

  • @ahmedmontaser4581
    @ahmedmontaser4581 4 місяці тому

    يا باشمهندس اسامة انا قلتله ان لو direction يساوي left يبدأ يعد الهاشز و لو تساوي right يعدي الهاشز بالعكس فهل دا هيكون احسن من حيث time complexity لانه مش مطلوب منه يعد عدد الهاشز لو direction مش زي اللي في condition ؟

  • @ReemDia-dw4se
    @ReemDia-dw4se 4 місяці тому

    جزاك الله خيرا حقييقي حجات بتخلينا نفكر
    وعندي سؤال لو عندي حلين بطريقتين مختلفتين اعرف ايه فيهم احسن ازاي؟

  • @_S_R_10
    @_S_R_10 Місяць тому

    و عليكم السلام ورحمة الله وبركاته

  • @ma7mod_raslan
    @ma7mod_raslan 4 місяці тому +1

    عايزين كورس network ي بشمهندس

  • @odehnedal7373
    @odehnedal7373 4 місяці тому

    السلام عليكم
    string Trim_String(string st, string direction = "All", char ch = ' ')
    {
    int fisrtcharcount = 0;
    int lastcharcount = st.length()-1;
    string result;
    if (direction == "Left" || direction == "All")
    for (int i = 0; i = 0; i--)
    if (st[i] == ch)
    lastcharcount--;
    else
    break;

    for (int i = fisrtcharcount; i

  • @itsmeagain1415
    @itsmeagain1415 4 місяці тому

    انا بالنسبالي لو هنفذ حاجة زي دي في الغالب هستعمل enum و في كود الإختيارات هادمج التلاتة في بعض😅
    يعني مثلا:
    enum direction { all, right, left };
    string trim_string(string str, direction d=direction::all, char ch=' ') {
    size_t first = 0, last = str.size() - 1;
    while (d != right && str[first] == ch) first++;
    while (d != left && str[last] == ch) last--;
    return string(str.begin() + first, str.begin() + last);
    }
    تعديل: انا كتبت الكود في تعليق اليوتيوب كتحدي لنفسي و الحمد لله مغلطتش كتير فيه غلطتين بس😅
    واحدة ممكن تحصل في كلمة right, left فنخليها أحسن direction::right, direction::left
    و التانية في آخر سطر المفروض تقوله last + 1 مش last بس لأنه المفروض تعدي آخر الstring مش تقف عنده

  • @محمدطه-ك3ش3ح
    @محمدطه-ك3ش3ح 4 місяці тому +2

    string trim_string(string str , string dirction ="All",char ch =' '){
    string resulte ;
    int start = 0, end =str.size();
    if(dirction == "All"){
    for(int i =0;i

  • @AbdulrahmanMohamedAhmed
    @AbdulrahmanMohamedAhmed 4 місяці тому

    string trim_string(string st, string direction = "All", char ch = ' ')
    {
    string result;
    for (int i = 0; i < st.size(); i++)
    {
    if (direction == "All" && st[i] != ch) result += st[i];
    else if (direction == "Left" && st[i] != ch) for (; i < st.size(); i++) result += st[i];
    else if (direction == "Right")
    {
    result += st[i];
    if (st[i] != ch && st[i + 1] == ch) break;
    }
    }
    return result;
    } رايك يبروفيسور

  • @lg7t
    @lg7t 3 місяці тому +1

    #include

    using namespace std ;
    string Trim_String(string str , string Direction = "All" , char ch = ' ')
    {
    string result ;
    int First_Chars = 0 ;
    int Last_Chars = 0 ;

    for(auto s : str)
    {
    if(s == ch)
    First_Chars += 1 ;
    else
    break ;
    }
    for(int i = str.length() - 1 ; i >= 0 ; i--)
    {

    if(str[i] == ch)
    Last_Chars += 1 ;
    else
    break ;
    }

    for(int i = 0 ; i < str.size() ; i++)
    {
    if(Direction == "All")
    {
    if (i > First_Chars - 1 && i < str.length() - Last_Chars ) result.push_back(str[i]) ;
    } else if (Direction == "Left")
    {
    if (i >= First_Chars && i < str.size()) result.push_back(str[i]) ;
    }else
    {
    if(i >= 0 && i < str.length() - Last_Chars ) result.push_back(str[i]) ;
    }
    }
    return result ;
    }
    int main()
    {
    cout

  • @mazenmohamed-nh1kt
    @mazenmohamed-nh1kt 4 місяці тому

    string trim_string(string st, string direction = "All", char ch = ' ')
    {
    string result;
    int fristcount = 0, seccount = 0;
    for (int i = 0; i < st.length() / 2; i++)
    if (st[i] == ch) fristcount++;
    for (int i = st.length() - 1; i >= st.length() / 2; i--)
    if (st[i] == ch) seccount++;
    if (direction == "All")
    {
    for (int i = fristcount; i < st.length() - seccount; i++)
    result += st[i];
    }
    else if (direction == "Left")
    {
    for (int i = fristcount; i < st.length(); i++)
    result += st[i];
    }
    else if(direction == "Right")
    {
    for (int i = 0; i < st.length() - seccount; i++)
    result += st[i];
    }
    return result;
    }
    void main()
    {
    cout

  • @smsm5769
    @smsm5769 4 місяці тому +1

    string trim_string(string str , char trim , string dir = "All" )
    {
    int si = str.length() / 2 ;
    if(dir == "left")// tarekek###
    {
    auto newEnd = remove(str.begin(), str.end(), trim);
    str.erase(newEnd, str.end()- si);
    }
    else if(dir == "right") // ###tarek
    {
    str.erase(remove(str.begin() + si, str.end() , trim ), str.end());
    }
    else // ###tarek###
    {
    str.erase(remove(str.begin(), str.end(), trim ), str.end());
    }
    return str ;
    }

  • @soussiaaziz6578
    @soussiaaziz6578 4 місяці тому

  • @Mahmoud_Elsayed_22
    @Mahmoud_Elsayed_22 3 місяці тому

    #include
    using namespace std;
    string TrimLeft(string name)
    {
    for (int i = 0; i < name.size(); i++)
    {
    if (name[i] != '#')
    {
    return name.substr(i, name.size() - i);
    }
    }
    return "";
    }
    string TrimRight(string name)
    {
    for (int i = name.size() - 1; i >= 0; i--)
    {
    if (name[i] != '#')
    {
    return name.substr(0, i + 1);
    }
    }
    return "";
    }
    string Trim(string name)
    {
    return TrimRight(TrimLeft(name));
    }
    int main()
    {
    string name = "#########mahmoud elsayed#########";
    cout

  • @Mahmoud_Elsayed_22
    @Mahmoud_Elsayed_22 3 місяці тому

    #include
    using namespace std;
    string Trim(string name, string direction = "All", char seperator = ' ')
    {
    string result = "";
    short FirstCharCount = 0;
    short LastCharCount = 0;
    for (int i = 0; i < name.length(); i++)
    {
    if (name[i] == seperator)
    FirstCharCount++;
    else
    break;
    }
    for (int i = name.length() - 1; i >= 0; i--)
    {
    if (name[i] == seperator)
    LastCharCount++;
    else
    break;
    }
    if (direction == "Left")
    for (int i = FirstCharCount; i < name.length(); i++)
    result += name[i];
    else if (direction == "Right")
    for (int i = 0; i < name.length() - LastCharCount; i++)
    result += name[i];
    else if (direction == "All")
    for (int i = FirstCharCount; i < name.length() - LastCharCount; i++)
    result += name[i];
    return result;
    }
    int main()
    {
    string name = "#########mahmoud elsayed#########";
    cout

  • @OmarHany-uz5om
    @OmarHany-uz5om 4 місяці тому

    string trim_string(string st, string direction = "All", char ch = ' ')
    {
    string result = "";
    if (direction == "All") for (int i = 0; i < st.length(); i++) if (st[i] != ch) result += st[i];
    if (direction == "Right")
    {
    for (int i = st.length() - 1; i >= 0; i--)
    {
    if (st[i] != ch)
    {
    for (int j = 0; j

  • @ahmedalswesy1
    @ahmedalswesy1 4 місяці тому

    جزاك الله خيرا

  • @abdullahajaj3196
    @abdullahajaj3196 4 місяці тому

  • @mahmoudramadan1366
    @mahmoudramadan1366 4 місяці тому +3

    اي حد بيذاكر الكورس من البداية وفاهم اللى فات يا ريت يكلمنى ابعتله الواتس بتاعى عشان محتاج افهم حجات كتير وجزاكم الله خيراً🩵🩵

    • @dh.3234
      @dh.3234 4 місяці тому

      تفضل