Mavzu: Kantenerlar bilan ishlash Konteynerlar


getline( cin, s1); // Read the first


Download 173.5 Kb.
bet10/12
Sana21.06.2023
Hajmi173.5 Kb.
#1640460
1   ...   4   5   6   7   8   9   10   11   12
Bog'liq
Mavzu abbos

getline( cin, s1); // Read the first

getline( cin, s2); // and second line.

if( line1 == line2)

cout << " Satrlar bir xil" << endl;

else cout<<"Ular br xil emas";

return 0; }

#include

#include

#include

using namespace std;

int main(){

string s1, s2;

getline( cin, s1); // Read the first

getline( cin, s2); // and second line.

s1>s2?cout<

return 0; }

Solishtirish natijalari


  • 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.

Қатор қўшиш ва олиб ташлаш INSERTING AND ERASING IN STRINGS

Inserting a string

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);

Download 173.5 Kb.

Do'stlaringiz bilan baham:
1   ...   4   5   6   7   8   9   10   11   12




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling