Gulyamova. D tekshirdi: Cho’liyev. Sh


Download 244.99 Kb.
Sana17.08.2023
Hajmi244.99 Kb.
#1667929
Bog'liq
5-Lobaratoriya


MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

431-21-guruh talabasi Zayniddinov Najmiddinning dasturlash fanidan lаbaratoriya ishi


Tekshirdi: Gulyamova.D


Tekshirdi: Cho’liyev.SH

Berilgan ikkita satrdagi bir xil belgilar sonini aniqlaydigan dastur tuzing.



int countPairs(string s1, int n1, string s2, int n2)
{
int freq1[26] = { 0 };
int freq2[26] = { 0 };
int i, count = 0;
for (i = 0; i < n1; i++)
freq1[s1[i] - 'a']++;
for (i = 0; i < n2; i++)
freq2[s2[i] - 'a']++;
for (i = 0; i < 26; i++)
count += (min(freq1[i], freq2[i]));

return count;


}
int main()
{
string s1,s2;
cout<<"birinchi satrni kiriting: ";cin>>s1;
cout<<"ikkinchi satrni kiriting: ";cin>>s2;
int n1 = s1.length(), n2 = s2.length();
cout <<"O'xshash belgilar soni: "<< countPairs(s1, n1, s2, n2)<<" ta";

return 0;


}
char turidagi satrdan juft uzunlikdagi soʻzlarni toq uzunlkdagi soʻzlar bilan almashtiradigan dastur tuzing.

int main()
{
int i,k=-1,m=0;
char c[100],a[100],b[i];
cout<<"Satr kiriting: ";
cin.getline(c,sizeof(c));
cout<<"Javob: ";
for (i=1;i<=strlen(c);i++)
if (i%2==1)
a[2*i]=c[i];
else
a[i-1]=c[i];
for (i=1;i<=strlen(c);i++)
cout<}
Download 244.99 Kb.

Do'stlaringiz bilan baham:




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