Why my bubble sort is code is not work on sololearn compiler? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why my bubble sort is code is not work on sololearn compiler?

This is the code--- //Program to sort an array using Bubble Sort #include <iostream> using namespace std; int main() { int a[50],i,n,item; int temp,loc; cout<<"Enter the size = "<<endl; cin>>n; for(i=1;i<=n;i++) { cout<<"a["<<i<<"]= "; cin>>a[i]; } for(int k=1;k<=n;k++) { for(i=1;i<=n-1;i++) { if(a[i]>a[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; } } } cout<<"----------------------------------"<<endl; cout<<"sorted list is :"<<endl; for(i=1;i<=n;i++) { cout<<"a["<<i<<"]="<<a[i]<<endl; } return 0; }

3rd Dec 2016, 6:31 PM
Shubham
Shubham - avatar
2 Answers
+ 2
because it has two cin >> . sololearn doesn't support to enter an input each time the code reaches it . instead you have to enter the values separated by spaces in one go. disappointing .
3rd Dec 2016, 6:44 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
oh thanks
3rd Dec 2016, 6:45 PM
Shubham
Shubham - avatar