Jump to content

AJUDA COM LINGUAGEM C!


antonio ryan

Recommended Posts

Pessoal, boa tarde . Sou iniciante em linguagem C, e por isso estou com dificuldades pra conseguir identificar o erro. Me digam por favor o que está errado nesse código, e me digam como resolver!!

professor me passou 1 exercicios para resolver e não estou conseguindo achar o erro!

1º Apresente o funcionamento do algoritmo de ordenação INSERÇÃO, iteração por iteração,
   dos seguintes vetores: [50,20,10,15,21];

 

 
#include <stdio.h>
void sort(int *arr, int size);
 
int main(){
int a [] = {50, 20, 10, 15, 21};
sort(a, 10);
 
for(int i = 0; i < 10; i++)
printf("%d\n", a);
return 0;
}
 
void sort(int *arr, int size){
int x, y, value;
 
for(x = 10; x < size; x ++){
value = arr[x];
 
for(y = x - 10; y >= 0 && arr[y] > value; y --){
arr[y+1] = arr[y];
}
arr[y+1] = value;
}
}
 
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...