cReTzUUUU Posted July 14, 2020 Posted July 14, 2020 /Sortarea prin interschimbare // se parcurge vectorul inversand continuturile elementelor alaturate care nu sunt crescatoare #include <iostream> using namespace std; int a[100], n, i,j ,k ,man, gasit ; int main() { cout<<"Dati dimensiunea tabloului n = "; cin>>n; for(i=0; i<n; i++) { cout<<"a["<<i<<"] = "; cin>>a[i]; } do { gasit=0; for(i=0; i<n-1; i++) if (a[i]>a[i+1]) { man=a[i]; a[i]=a[i+1]; a[i+1]=man; gasit=1; } } while (gasit); { cout<<"Tabloul ordonat crescator \n"; for(i=0; i<n; i++) cout<<a[i]<<" "; } }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now