Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
675 B
2
Indexable
Never
#include <iostream>
#define limit 100
using namespace std;
int main()
{
    int numbers[limit];
    int size;
    cout << "Enter the size number: ";
    cin >> size;
    for (int i = 0; i < size; i++)
    {
        cin >> numbers[i];
    }
    for (int i = 0; i < size; i++)
    {
        for (int j = 0; j < size - j; j++)
        {
            if (numbers[j] > numbers[j + 1])
            {
                int temp = numbers[j];
                numbers[j] = numbers[j + 1];
                numbers[j + 1] = temp;
            }
        }
    }
    for (int i = 0; i < size; i++)
    {
        cout << numbers[i] << ' ';
    }

    return 0;
}
Leave a Comment