#include<stdio.h>
int main() {
int temp;
int arr[6] = {30, 45, 12, 51, 19, 8};
for(int i = 1; i<=5; i++) {
for(int j = i; j>0; j--) {
if(arr[j-1] > arr[j]) {
temp = arr[j -1];
arr[j -1] = arr[j];
arr[j] = temp;
}
}
}
for(int k = 0; k<=5; k++) {
printf("%d ", arr[k]);
}
return 0;
}
Sunday, November 28, 2021
Insertion Sort (if pehle wala bada hai toh jagah change kar aise karte jaana hai condition for loop ke andar lagana hai)
Subscribe to:
Post Comments (Atom)
Priority queue deleting elements after ascending inputs Gaand Fadd
using namespace std; #include<iostream> #define N 5 class pq { public: int* arr; int front; int rear; pq() { ...
-
using namespace std; #include<stdio.h> #define N 5 class q{ public: int* arr; int front; int rear; q() { ...
-
#include<stdio.h> int fnCmp(char* str1, char* str2) { while( (*str1 != '\0' && *str2 != '\0') && ...
-
#include<stdio.h> void fncpy(char* str2, char* str1) { int i = 0; while(*str1 != '\0') { str2[i] = *str1; ...
No comments:
Post a Comment