1. «Hello World» satrini boshqa massivga belgima-belgi nusxalovchi dastur tuzing. */
}
}
/*
2.Satrdagi kichik harflarni bosh harflar bilan almashtiruvchi dastur tuzing. */
#include
using namespace std;
int main() {
int i,n;
string s;
getline(cin,s);
n=s.length();
for(i=0; i
if(islower(s[i])) s[i]=toupper(s[i]);
cout<
return 0;
}
/*
3. Kiritilgan satrdagi ‘s’ harflarini sanovchi dastur tuzing. */
#include
#include
#include
using namespace std;
int main() {
string s;
getline(cin,s);
int n = s.length();
int a = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 's') {
a = a+1;
};
}
cout<<"s harflari soni: "<
}
/*
4.Kiritilgan soʻzdan barcha ‘o’ harflarini oʻchiruvchi dastur tuzing.*/
#include
using namespace std;
int main()
{
string str;
getline(cin,str);
str.erase(std::remove(str.begin(), str.end(), 'o'), str.end());
cout << str;
return 0;
}
/*9.Kiritilgan satrni teskari tartibda chiqaruvchi dastur tuzing. */
#include
using namespace std;
int main()
{
string str;
getline(cin,str);
// Reverse str[beign..end]
reverse(str.begin(), str.end());
cout << str;
return 0;
}
/*
12. Kiritilgan satrdagi barcha ‘O’ harflarini kichik harflarga almashtiruvchi dastur tuzing.*/
#include
using namespace std;
int main()
{
string str;
getline(cin,str);
replace (str.begin(), str.end(), 'O' , 'o');
cout << str;
return 0;
}
/*
13.Uchta “The laboratory”, “work” va “№8” satrlarini toʻrtinchi satrda birlashtiruvchi dastur tuzing.*/
#include
using namespace std;
int main()
{
char s1[] = "The laboratory ";
cout<
char s2[] = "work ";
cout<
char s3[] = "№8";
cout<
strcat(s1, s2);
strcat(s1, s3);
cout<
return 0;
}
/*
15.Kiritilgan satrdagi barcha ‘i’ harflarini sanovchi va chiqaruvchi dastur tuzing.*/
#include
#include
#include
using namespace std;
int main() {
string s;
getline(cin,s);
int n = s.length();
int a = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'i') {
a = a+1;
};
}
cout<<"i harflari soni: "<
}
Do'stlaringiz bilan baham: