Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Runtime error (SIG SEGV)

$
0
0

Solving following question: http://www.codechef.com/problems/TSORT/

Getting above error for following code:

#include <iostream>
using namespace std;
int arr[10000];
void sort(int arr[], int n) {
    for(int i=n-2;i>=0;i--){
        for(int j=0; j<=i;j++){
            if(arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
            }
        }
    }
}
int main()
{

    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr,n);
        for(int i=0; i< n; i++){
        cout<<endl;
        cout<<arr[i];
    }
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>