|
Mavzu: Standart taqsimlash Сатрлар ва кенгайтирилган белгиларgetline( cin, s2); // and second line
|
səhifə | 3/3 | tarix | 26.05.2023 | ölçüsü | 20,16 Kb. | | #113178 |
| Standart taqsimlashgetline( cin, s2); // and second line. if( line1 == line2) cout << " Satrlar bir xil" << endl; else cout<<"Ular br xil emas"; return 0; } #include #include #include int main(){ string s1, s2; getline( cin, s2); // and second line. s1>s2?cout< return 0; }
Solishtirish natijalari bool mantiqiy tipi orqali amalga oshiriladi. s1 va s2 satrlari uchun:
s1 == s2 TRUE bo’ladi agar har ikkalasini qiymati bir hilda bo’lsa (satr uzunligi bir hil bo’lishi lozim).
s1 < s2 TRUE bo’ladi agarda s1 ning simvoli uzunligi, s2 ning simvoli uzunligidan farq qilsa.
string s1("Miss Summer"); s1.insert(5, "Ashley "); // Insert at position: 5 cout< Erasing a substring string s("The summer-time"); s.erase(4,7); // Start position: 4, Quantity: 7 cout< string s("winter-story"); string s("winter-story"); s.erase(6); // s now contains "winter" cout< erase( ); argumentsiz berilsa satr to’liq o’chiriladi Қатор ўрнини эгаллаш ва қатор қидируви. SEARCHING AND REPLACING IN STRINGS string s1("There they go again!"), s2("Bob and Bill"); s1.replace(6, 4, s2); cout<
s1.replace(6, 4, s2);
string s1("Here comes Mike!"), string s1("Here comes Mike!"), s2("my love?"); s1.replace(11, 4, s2, 0, 7); cout<
s1.replace(11, 4, s2, 0, 7);
Searching string youth("Bill is so young, so young"); int first = youth.find("young"); cout<
Dostları ilə paylaş: |
|
|