MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
SWD016 guruh talabasi
DAMINOV BAHODIRning
“Ma’lumotlar Tuzilmasi Va Algaritimlar” fanidan tayyorlagan
2-amaliyot ishi
O’qituvchi: Axmadjonov Islomjon
kodi
#include
using namespace std;
void bubbleSort(int arr[], int n) {
bool isUnsorted;
do {
isUnsorted = false;
for (int i = 0; i < (n - 1); i++) {
if (arr[i] > arr[i + 1]) {
isUnsorted = true;
for (; i < (n - 1); i++) {
if (arr[i] > arr[i + 1]) {
std::swap(arr[i], arr[i + 1]);
}
}
}
}
} while (isUnsorted);
}
void printarrray(int arr[], int n)
{
for(int i=0; i
{
cout<
}
}
int printArray(int arr[], int n)
{
int min = 0;
min = -100000;
for(int i = 0; i < n; i++)
{
if(arr[i]<0 && min
{
min = arr[i];
}
}
cout<<"manfiy min = "<
}
int main()
{
int n;
cout<<"n: ";cin>>n;
int arr[n];
int N = sizeof(arr)/sizeof(arr[0]);
for(int i=0; i
{
cout<<"arr["<>arr[i];
}
bubbleSort(arr, N);
printarrray(arr, N);
cout <<"Pufakchasimon saralash: \n";
printArray(arr, N);
return 0;
}
0>
Do'stlaringiz bilan baham: |