C语言段违例,段错误例子

#include <stdio.h>
#include <stdlib.h>

void bubble(int *s,int length);
void swap(int *p,int *q);

int main(){
      int j;
      int s[10] = {6,5,8,41,5,3,50,6,10};
     bubble(s,10);
     printf("the result of array is:/n");
      for(j = 0;j <10;j++)
         printf("%d",s[j]);
      printf("/n");  

     system("pause");
   }
  
     
void bubble(int *s,int length){
     int i,j;
     for(i = 0;i < length;i++){
        for(j = length-1;j > i;j--){
            if (*(s+i) > *(s+j))
              swap((s+i),(s+j));      
        }           
     }
}


void swap(int *p,int *q){
     int temp;
          temp = *p;
          *p = *q;
          *q = temp;
}
出现段违例怎么解决?

你可能感兴趣的:(C语言段违例,段错误例子)