+ 1
Difference between these two-
https://code.sololearn.com/csU79fw41EGr/?ref=app AND #include <iostream> using namespace std; int main() { int a [20],i,j,n,k; cout<<"enter n\n"; cin>>n; cout<<"enter the array\n"; for (i=0;i<n;i++) cin>>a [i]; for (i=1;i<n;i++) { k=a [i]; for (j=i-1;j>=0;j--) {if (k <a [j]) a [j+1]=a [j]; } a [j+1]=k; } cout<<"sorted array is\n"; for (i=0;i<n;i++) cout<<a [i]<<endl; return 0; }
1 Answer