• cout cout cout getch();
  • include inclde using namespace std; int main(){ string s1=”01234567893456ab2csef”,s2 =”456”,s3=”ghk”;
  • Mavzu: satrlar va kengaytirilgan belgilar ishning maqsadi




    Download 282,05 Kb.
    Pdf ko'rish
    bet6/8
    Sana21.07.2024
    Hajmi282,05 Kb.
    #268145
    1   2   3   4   5   6   7   8
    int main(){
     string s1=”01234567893456ab2csef”,s2 =”456”,s3=”ghk2”; 
    int i,j; i=s1.find(s2); j=s1.rfind(s2);
    cout << i; // 4 
    cout << j; // 11 
    cout << s1.find(‘3’) <
    cout << s1.rfind(‘3’) <
    cout << s1.find_first_of (s3) <
    cout << s1.find_last_of (s3) <
    cout << s1.find_first_not_of (s2) <
    cout << s1.find_last_not_of (s2) <
    getch(); 
    }
     
    Satrni qismini solishtirish


    Satrlarni to‘liq solishtirish uchun solishtirish amallari ishlatiladi, qismini 
    solishtirish uchun compare funksiyasi ishlatiladi: 
    int compare ( const string &str) const; 
    int compare (unsigned int pos1, unsigned int n1, const string & str) const; 
    int compare (unsigned int pos1, unsigned int n1, const string & str, unsigned 
    int pos2, unsigned int n2) const; 
    Funksiya ni birinchi shakli ikki satrni butunlay solishtiradi va manfiy son 
    qaytaradi chaqiruvchi satr str dan kichik bo‘lsa, 0 qaytaradi agar ular teng bo‘lsa va 
    musbat son qaytaradi chaqiruvchi satr katta bo‘lsa. 
    Ikkinchi shaklda xudii oldingiday amallar bajariladi faqat chaqiruvchi satrni 
    pos1 o‘rnidan boshlab n1 ta belgili satr str satr bilan solishtiriladi. 
    Uchinchi shaklda chaqiruvchi satrdan pos1 o‘rnidan boshlab n1 ta belgi va 
    str satrdan ros2 o‘rnidan boshlab n2 ta belgi o‘zaro solishtiriladi. 
    Yangi va eski turdagi satrlarni solishtirish yuqorida ko‘rsatilganday 
    funksiyalar mavjud. Misol: 
    #include  
    #inclde  
    using namespace std; 
    int main(){ 
    string s1=”01234567893456ab2csef”,s2 =”456”,s3=”ghk”; 
    cout << “s1=”<

    Download 282,05 Kb.
    1   2   3   4   5   6   7   8




    Download 282,05 Kb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Mavzu: satrlar va kengaytirilgan belgilar ishning maqsadi

    Download 282,05 Kb.
    Pdf ko'rish