Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cocktail Sort In C/C++ #8708

Open
1 task done
TechnoPhasePRO opened this issue Nov 28, 2021 · 4 comments
Open
1 task done

Cocktail Sort In C/C++ #8708

TechnoPhasePRO opened this issue Nov 28, 2021 · 4 comments
Assignees
Labels
Assigned Assigned to some work C/CPP documentation Improvements or additions to documentation GWOC21

Comments

@TechnoPhasePRO
Copy link

Description

Cocktail Sort in c.

Domain

C/CPP

Type of Contribution

Documentation

Code of Conduct

@keywordlabeler keywordlabeler bot added C/CPP documentation Improvements or additions to documentation labels Nov 28, 2021
@TechnoPhasePRO
Copy link
Author

/assign

@github-actions
Copy link

Hello @TechnoPhasePRO,
Thank you for opening an issue. :octocat:
Note - Self-assigns by the original author will be prioritised by mentors manually
To get assigned to this particular issue please use /assign
Check this guide before contributing.

@github-actions github-actions bot added the Assigned Assigned to some work label Nov 28, 2021
@github-actions
Copy link

This issue has been assigned to @TechnoPhasePRO!
It will become unassigned if it isn't closed within 12 days. A maintainer can also add the pinned label to prevent it from being unassigned.

@ssurbhi09
Copy link

#include
using namespace std;
int main() {
int arr[] = { 5, 3, 4, 2, 1 };
int m=5;
int n, c;
n=m;
do {
for (int i = 0; i < n - 1; i++) {
if (arr[i] > arr[i + 1]) {
arr[i] = arr[i] + arr[i + 1];
arr[i + 1] = arr[i] - arr[i + 1];
arr[i] = arr[i] - arr[i + 1];
}
}
n = n - 1;
for (int i=m-1, c = 0; i >= c; i--) {
if(arr[i] < arr[i - 1]) {
arr[i] = arr[i] + arr[i - 1];
arr[i - 1] = arr[i] - arr[i - 1];
arr[i] = arr[i] - arr[i - 1];
}
}
c = c + 1;
}
while (n != 0 && c != 0);
for (int i = 0; i < m; i++) {
cout<< arr[i]<<"\t";
}
}

Is it true??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Assigned Assigned to some work C/CPP documentation Improvements or additions to documentation GWOC21
Projects
None yet
Development

No branches or pull requests

2 participants