+ 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; }
2 ответов
+ 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 .
0
oh thanks