Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- int a[20];
- for (int i = 0; i < 20; i++)
- {
- a[i] = rand() % 99 + 1;
- printf("%d ", a[i]);
- }
- int j = 19;
- for (int i = 0; i < 20 && i<j; i++)
- {
- if (a[i] < 50)
- {
- }
- else
- {
- for (; j >= 0; j--)
- {
- if (i >= j)
- {
- break;
- }
- if (a[j] > 50)
- {
- }
- else
- {
- std::swap(a[i], a[j]);
- j--;
- break;
- }
- }
- }
- }
- printf("\n");
- for (int i = 0; i < 20; i++)
- {
- printf("%d ", a[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement