winter-of-contributing icon indicating copy to clipboard operation
winter-of-contributing copied to clipboard

Cocktail Sort In C/C++

Open yashrsb opened this issue 4 years ago • 4 comments

Description

Cocktail Sort in c.

Domain

C/CPP

Type of Contribution

Documentation

Code of Conduct

yashrsb avatar Nov 28 '21 12:11 yashrsb

/assign

yashrsb avatar Nov 28 '21 12:11 yashrsb

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[bot] avatar Nov 28 '21 12:11 github-actions[bot]

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.

github-actions[bot] avatar Nov 28 '21 12:11 github-actions[bot]

#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??

ssurbhi09 avatar Dec 26 '21 18:12 ssurbhi09