Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main(){
- srand(time(NULL));
- int N;
- cin >> N;
- int nums[N];
- for (int i=0;i<N;i++){
- cin >> nums[i];
- //nums[i] = rand()%100000+1;
- }
- for (int j=0;j<N-1;j++){
- int F = 0;5
- for (int i=0;i<N-j;i++){
- if (nums[i] > nums[i+1]) {
- swap(nums[i],nums[i+1]);
- F = 1;
- if (F == 0) break;
- }
- }
- }
- for (int i = 0; i < N; i++){
- if (i == N-1) {
- cout << nums[i];
- }
- else{
- cout << nums[i] << "-->";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement